pubkey/rxdb · error · RxError
DOC14
DOC14
Error message
RxDB Error-Code: DOC14. 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
DOC14 is thrown by the base RxDocument prototype close() method, which is another stub that must be overwritten by a plugin. There is no per-document close in RxDB core, so calling close() on a document instance always throws unless a plugin implements it.
Source
Thrown at src/rx-document.ts:442
this.primary,
this._data,
error
);
}
return removeResult.success[0];
},
incrementalRemove(this: RxDocument): Promise<RxDocument> {
return this.incrementalModify(async (docData) => {
await this.collection._runHooks('pre', 'remove', docData, this);
docData._deleted = true;
return docData;
}).then(async (newDoc) => {
await this.collection._runHooks('post', 'remove', newDoc._data, newDoc);
return newDoc;
});
},
close() {
throw newRxError('DOC14');
}
};
export function createRxDocumentConstructor(proto = basePrototype) {
const constructor = function RxDocumentConstructor(
this: RxDocument,
collection: RxCollection,
docData: RxDocumentData<any>
) {
this.collection = collection;
// assume that this is always equal to the doc-data in the database
this._data = docData;
/**
* @performance
* Lazy-initialize _propertyCache only when first needed
* instead of creating a new Map for every RxDocument,View on GitHub (pinned to af6fb65f94)
Solutions
- Remove the doc.close() call; RxDocuments have no close method and need no explicit cleanup.
- If you meant to close the database, call rxDatabase.close() instead.
- If you meant to delete the document, use await doc.remove() instead.
Example fix
// before await doc.close(); // after await doc.remove(); // delete the document // or: await db.close(); // close the whole database
Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof (doc as any).close === 'function' && doc.collection) {
throw new Error('RxDocument has no close(); use db.close() or doc.remove()');
} Type guard
function isDatabaseLike(obj: unknown): obj is { close(): Promise<void> } {
return typeof obj === 'object' && obj !== null && 'collections' in obj && 'close' in obj;
} Try / catch
try {
await resource.close();
} catch (err) {
if (err?.code === 'DOC14') {
console.warn('called close() on an RxDocument; no-op');
} else {
throw err;
}
} Prevention
- Only call close() on RxDatabase instances; type cleanup helpers narrowly instead of any handle with close().
- Use doc.remove() for document deletion and db.close() for shutdown.
- Enable the dev-mode plugin in development so stub-method misuse is explained.
When it happens
Trigger: Calling doc.close() on an RxDocument instance, likely by confusing the document API with the database or collection API, or following code written for a different database wrapper.
Common situations: Copy-pasted cleanup code where rxDatabase.close() was intended; generic resource-cleanup helpers that call close() on every handle including documents.
Related errors
AI-assisted analysis of pubkey/rxdb@af6fb65f94 (2026-08-31).
Data as JSON: /api/errors/69d2d569a3a50529.
Report an issue: GitHub.