pubkey/rxdb · error · RxError

DB12

DB12

Error message

RxDB Error-Code: DB12. Hint: Error messages are not included in RxDB core to reduce build size. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error

What it means

DB12 is thrown when writing the internal collection metadata documents during addCollections() and the storage returns a write error with a status other than 409 (conflict). A 409 is handled (schema-compare logic), but any other status means the internal store failed unexpectedly, so RxDB surfaces the raw write error wrapped in DB12.

Source

Thrown at src/rx-database.ts:454

        /**
         * If the ensureNoStartupErrors or the bulkWrite error handling throws,
         * we must close any pre-created storage instances to avoid resource leaks.
         */
        let putDocsResult;
        try {
            [putDocsResult] = await Promise.all([
                this.internalStore.bulkWrite(
                    bulkPutDocs,
                    'rx-database-add-collection'
                ),
                ensureNoStartupErrors(this)
            ]);

            await Promise.all(
                putDocsResult.error.map(async (error) => {
                    if (error.status !== 409) {
                        throw newRxError('DB12', {
                            database: this.name,
                            writeError: error
                        });
                    }
                    const docInDb: RxDocumentData<InternalStoreCollectionDocType> = ensureNotFalsy(error.documentInDb);
                    const collectionName = docInDb.data.name;
                    const schema = (schemas as any)[collectionName];
                    // collection already exists but has different schema
                    if (docInDb.data.schemaHash !== await schema.hash) {
                        throw newRxError('DB6', {
                            database: this.name,
                            collection: collectionName,
                            previousSchemaHash: docInDb.data.schemaHash,
                            schemaHash: await schema.hash,
                            previousSchema: docInDb.data.schema,
                            schema: ensureNotFalsy((jsonSchemas as any)[collectionName])
                        });
                    }

View on GitHub (pinned to af6fb65f94)

Solutions

  1. Inspect error.writeError.status in the dev-mode plugin output to identify the underlying storage failure.
  2. Free up storage/quota (IndexedDB quota) or switch to a storage with more capacity.
  3. Close and recreate the database/storage; ensure no code closed the underlying RxStorage before addCollections.
  4. If it appears after a RxDB upgrade, the on-disk data may be incompatible: migrate the data or start with cleared storage.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await db.addCollections(defs);
} catch (err) {
  if (isRxError(err) && err.code === 'DB12') {
    const status = err.parameters?.writeError?.status;
    console.error('Internal store write failed during addCollections, status:', status);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: bulkWrite of the internal collection docs in addCollections() fails with a non-409 error, e.g. storage-level failures (quota exceeded, storage closed, invalid document, IO error) while creating collections.

Common situations: IndexedDB quota exceeded in the browser; using a storage instance that was already closed; storage adapter bugs or mismatched internal store schema after a RxDB major upgrade with an old on-disk internal store.


AI-assisted analysis of pubkey/rxdb@af6fb65f94 (2026-08-31). Data as JSON: /api/errors/e4840251f4774c02. Report an issue: GitHub.