pubkey/rxdb · error · RxError
DB9
DB9
Error message
RxDB Error-Code: DB9. 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
DB9 is thrown when you pass { ignoreDuplicate: true } to createRxDatabase() while the dev-mode plugin is not enabled. The ignoreDuplicate option is a dev-only convenience for hot reloading, so RxDB refuses it in production builds to prevent silently sharing an underlying storage between database instances. Enable the dev-mode plugin to use it during development.
Source
Thrown at src/rx-database.ts:857
};
databaseNameKeyUnclosedInstancesSet.add(instancePromiseWithResolvers.promise as any as Promise<RxDatabase>);
DATABASE_UNCLOSED_INSTANCE_PROMISE_MAP.set(databaseNameKey, databaseNameKeyUnclosedInstancesSet);
(async () => {
if (closeDuplicates) {
await Promise.all(
closeDuplicatesPromises.map((unclosedInstancePromise) =>
unclosedInstancePromise
.catch(() => null)
.then((instance) => instance && instance.close())
)
);
}
if (ignoreDuplicate) {
if (!overwritable.isDevMode()) {
throw newRxError('DB9', {
database: name
});
}
} else {
// check if combination already used
throwIfDatabaseNameUsed(name, storage);
}
USED_DATABASE_NAMES.add(databaseNameKey);
const databaseInstanceToken = randomToken(10);
const storageInstance = await createRxDatabaseStorageInstance<
Internals,
InstanceCreationOptions
>(
databaseInstanceToken,
storage,
name,View on GitHub (pinned to af6fb65f94)
Solutions
- Remove ignoreDuplicate from createRxDatabase options in production code.
- If it is dev-only tooling, register the dev-mode plugin: addRxPlugin(RxDBDevModePlugin) when process.env.NODE_ENV !== 'production'.
- Reuse a singleton database instance instead of relying on ignoreDuplicate.
Example fix
// before
const db = await createRxDatabase({ name: 'mydb', storage, ignoreDuplicate: true });
// after
import { RxDBDevModePlugin } from 'rxdb/plugins/dev-mode';
if (process.env.NODE_ENV !== 'production') {
addRxPlugin(RxDBDevModePlugin);
}
const db = await createRxDatabase({
name: 'mydb',
storage,
...(process.env.NODE_ENV !== 'production' ? { ignoreDuplicate: true } : {})
}); Defensive patterns
Strategy: validation
Validate before calling
import { RxDBDevModePlugin } from 'rxdb/plugins/dev-mode';
import { addRxPlugin } from 'rxdb';
const isDev = process.env.NODE_ENV !== 'production';
if (isDev) addRxPlugin(RxDBDevModePlugin);
if (!isDev && options.ignoreDuplicate) {
throw new Error('ignoreDuplicate is only allowed in dev mode');
} Type guard
function isIgnoreDuplicateAllowed(isDevMode, options) {
return !options.ignoreDuplicate || isDevMode === true;
} Try / catch
try {
db = await createRxDatabase(options);
} catch (err) {
if (String(err?.code) === 'DB9') {
// ignoreDuplicate without dev-mode plugin: drop the option and retry
const { ignoreDuplicate, ...rest } = options;
db = await createRxDatabase(rest);
} else {
throw err;
}
} Prevention
- Only pass ignoreDuplicate in code paths gated behind NODE_ENV development checks.
- Register RxDBDevModePlugin in the same environment gate as ignoreDuplicate usage.
- Prefer singleton database instances over ignoreDuplicate for hot reloading.
- Never ship ignoreDuplicate in production bundles.
When it happens
Trigger: Calling createRxDatabase({ name, storage, ignoreDuplicate: true }) without adding the dev-mode plugin via addRxPlugin(RxDBDevModePlugin), or with it enabled only conditionally in a production build.
Common situations: Copy-pasting hot-reload example code into a production build; toggling dev-mode plugin per environment so production hits this path; forgetting to register RxDBDevModePlugin after adding ignoreDuplicate.
Related errors
AI-assisted analysis of pubkey/rxdb@af6fb65f94 (2026-08-31).
Data as JSON: /api/errors/3d14319a64adc989.
Report an issue: GitHub.