{"record":{"id":"3c4b0077229f6b65","repo":"pubkey/rxdb","slug":"snh-3c4b00","errorCode":"SNH","errorMessage":"\n        RxDB Error-Code: ${message}.\n        Hint: Error messages are not included in RxDB core to reduce build size.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error\n        \nFind out more about this error here: https://rxdb.info/errors.html?console=errors#SNH \nStill stuck? Ask in the RxDB Discord: https://rxdb.info/chat \n","messagePattern":"\n        RxDB Error-Code: (.+?)\\.\n        Hint: Error messages are not included in RxDB core to reduce build size\\.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb\\.info/dev-mode\\.html\\?console=error\n        \nFind out more about this error here: https://rxdb\\.info/errors\\.html\\?console=errors#SNH \nStill stuck\\? Ask in the RxDB Discord: https://rxdb\\.info/chat \n","errorType":"error_code","errorClass":"RxError","httpStatus":null,"severity":"error","filePath":"src/rx-storage-helper.ts","lineNumber":500,"sourceCode":"            let operation: 'INSERT' | 'UPDATE' | 'DELETE';\n\n            if (previousDeleted && !documentDeleted) {\n                operation = 'INSERT';\n                /**\n                 * Reuse the already-stripped document from updatedRow\n                 * instead of calling stripAttachmentsDataFromDocument() again.\n                 */\n                eventDocumentData = hasAttachments ? updatedRow.document : document as any;\n            } else if (previous && !previousDeleted && !documentDeleted) {\n                operation = 'UPDATE';\n                eventDocumentData = hasAttachments ? updatedRow.document : document as any;\n                previousEventDocumentData = previous;\n            } else if (documentDeleted) {\n                operation = 'DELETE';\n                eventDocumentData = ensureNotFalsy(document) as any;\n                previousEventDocumentData = previous;\n            } else {\n                throw newRxError('SNH', { args: { writeRow } });\n            }\n\n            const event = {\n                documentId: docId,\n                documentData: eventDocumentData as RxDocumentData<RxDocType>,\n                previousDocumentData: previousEventDocumentData,\n                operation: operation\n            };\n            eventBulkEvents.push(event);\n        }\n    }\n\n    return {\n        bulkInsertDocs,\n        bulkUpdateDocs,\n        newestRow,\n        errors,\n        eventBulk,","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-storage-helper.ts#L482-L518","documentation":"SNH stands for 'should not happen' and marks an internal invariant violation. In categorizeBulkWriteRows (src/rx-storage-helper.ts:500), RxDB categorizes each bulk-write row into INSERT, UPDATE or DELETE events. If a successfully written row cannot be classified into one of these three operations, the state is impossible under RxDB's assumptions and SNH is thrown. This is a bug signal, not a validation error: user input that is wrong is normally rejected earlier with a dedicated error code.","triggerScenarios":"A row that passed conflict and validation checks but whose previous document state and deleted flags match none of the three expected combinations (previousDeleted&&!documentDeleted, previous&&!previousDeleted&&!documentDeleted, documentDeleted). In practice: a storage implementation or plugin (custom RxStorage, sharding, replication wrapper) feeding corrupted or inconsistent rows into categorizeBulkWriteRows, or a race where the underlying storage returns inconsistent bulk-write results.","commonSituations":"Developing or using a third-party RxStorage plugin that returns wrong previousDocument/deleted data from bulkWrite(); using an outdated or incompatible RxStorage/plugin version with a newer RxDB core; concurrent writes from multiple processes bypassing RxDB's conflict handling so the storage returns a state RxDB did not expect.","solutions":["Inspect err.parameters.args.writeRow to see the offending row (document, previous state, deleted flags).","Report it as a bug to RxDB (https://github.com/pubkey/rxdb/issues) including the writeRow parameters, because this branch marks an internal invariant violation.","Check that all RxDB plugins and any custom RxStorage are version-matched with the RxDB core version.","If a custom storage is involved, verify its bulkWrite() returns previousDocumentData and deleted flags consistent with the RxStorageInstance contract.","As a workaround, clear/repair the affected storage data so the inconsistent row state is removed, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await collection.bulkInsert(docs);\n} catch (err) {\n  if (err && err.code === 'SNH') {\n    // internal invariant violation: capture state and report as a bug\n    console.error('RxDB SNH in bulk write, row:', JSON.stringify(err.parameters.args, null, 2));\n    reportBug(err); // e.g. send to your error tracker\n    return;\n  }\n  throw err;\n}","preventionTips":["Keep RxDB core and all plugins (storages, replication, premium) on matching versions.","Avoid writing to the same RxStorage instance from multiple processes outside RxDB's conflict handling.","If you implement a custom RxStorage, test bulkWrite() against the RxDB storage test suite so previousDocument/deleted flags match the contract.","Treat any SNH occurrence as a bug report trigger, not something to code around."],"tags":["internal","should-not-happen","storage"],"backgroundTag":"internal-invariant-violation","analyzedSha":"af6fb65f94cd70558d74c23799eda11ff1c15224","analyzedAt":"2026-08-31T23:32:37.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}