pubkey/rxdb · error · Error
You are using a function which must be overwritten by a plug
Error message
You are using a function which must be overwritten by a plugin.
You should either prevent the usage of this function or add the plugin via:
import { ${pluginName} } from 'rxdb/plugins/${pluginKey}';
addRxPlugin(${pluginName});
What it means
exportJSON() is a stub in RxDB core that throws pluginMissing('json-dump'). Full-database JSON dump/import lives in the json-dump plugin, which must be added via addRxPlugin so the real implementation overwrites this stub. Calling the stub means the plugin was not added.
Source
Thrown at src/rx-database.ts:543
return this.idleQueue.requestIdlePromise();
}
/**
* Export database to a JSON friendly format.
*/
exportJSON(
_collectionsOrOptions?: string[] | RxDumpOptions,
_options?: RxDumpOptions
): Promise<RxDumpDatabase<Collections>>;
exportJSON(
_collectionsOrOptions?: string[] | RxDumpOptions,
_options?: RxDumpOptions
): Promise<RxDumpDatabaseAny<Collections>>;
exportJSON(
_collectionsOrOptions?: string[] | RxDumpOptions,
_options?: RxDumpOptions
): Promise<any> {
throw pluginMissing('json-dump');
}
addState<T = any>(_name?: string): Promise<RxState<T, Reactivity>> {
throw pluginMissing('state');
}
/**
* Import the parsed JSON export into the collection.
* @param _exportedJSON The previously exported data from the `<db>.exportJSON()` method.
* @note When an interface is loaded in this collection all base properties of the type are typed as `any`
* since data could be encrypted.
*/
importJSON(_exportedJSON: RxDumpDatabaseAny<Collections>): Promise<void> {
throw pluginMissing('json-dump');
}
backup(_options: BackupOptions): RxBackupState {
throw pluginMissing('backup');View on GitHub (pinned to af6fb65f94)
Solutions
- Import and add the plugin: import { RxDBJsonDumpPlugin } from 'rxdb/plugins/json-dump'; addRxPlugin(RxDBJsonDumpPlugin); before calling exportJSON.
- Add the plugin once at application startup, before any dump code runs.
- If you only need per-collection export, note collection.exportJSON also requires the same json-dump plugin.
Example fix
// before
const dump = await db.exportJSON();
// after
import { RxDBJsonDumpPlugin } from 'rxdb/plugins/json-dump';
import { addRxPlugin } from 'rxdb';
addRxPlugin(RxDBJsonDumpPlugin);
const dump = await db.exportJSON(); Defensive patterns
Strategy: fallback
Try / catch
try {
return await db.exportJSON();
} catch (err) {
if (typeof err.message === 'string' && err.message.includes('json-dump')) {
throw new Error('Add the json-dump plugin: addRxPlugin(RxDBJsonDumpPlugin)');
}
throw err;
} Prevention
- Register all optional plugins (json-dump, state, backup, leader-election) in a single central bootstrap module.
- Run a startup self-test in dev mode that touches plugin-backed methods.
- Never rely on side-effect imports for plugin registration; call addRxPlugin explicitly.
When it happens
Trigger: Calling db.exportJSON() (or the overload with collection names / RxDumpOptions) on a database created without the json-dump plugin registered.
Common situations: Forgetting `import { getRxStorageJSONDump } / wrappedValidate...` style plugin registration, specifically `addRxPlugin(RxDBJsonDumpPlugin)` from 'rxdb/plugins/json-dump'; following old docs that imported it implicitly; tree-shaking dropped the side-effect import.
Related errors
AI-assisted analysis of pubkey/rxdb@af6fb65f94 (2026-08-31).
Data as JSON: /api/errors/efa580cd508b7f72.
Report an issue: GitHub.