mongodb/node-mongodb-native · error · MongoParseError

${optionWord} ${Array.from(unsupportedOptions).join(', ')} $

Error message

${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported

What it means

Thrown when the union of URI query params and options object keys contains any key not present in the driver's OPTIONS table (connection_string.ts:362-372). This catches typos, removed options, and options that belong to other drivers. The message interpolates the offending key(s).

Source

Thrown at src/connection_string.ts:369

  if (allProvidedOptions.has('tls') || allProvidedOptions.has('ssl')) {
    const tlsAndSslOpts = (allProvidedOptions.get('tls') || [])
      .concat(allProvidedOptions.get('ssl') || [])
      .map(getBoolean.bind(null, 'tls/ssl'));
    if (new Set(tlsAndSslOpts).size !== 1) {
      throw new MongoParseError('All values of tls/ssl must be the same.');
    }
  }

  checkTLSOptions(allProvidedOptions);

  const unsupportedOptions = setDifference(
    allProvidedKeys,
    Array.from(Object.keys(OPTIONS)).map(s => s.toLowerCase())
  );
  if (unsupportedOptions.size !== 0) {
    const optionWord = unsupportedOptions.size > 1 ? 'options' : 'option';
    const isOrAre = unsupportedOptions.size > 1 ? 'are' : 'is';
    throw new MongoParseError(
      `${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`
    );
  }

  // Option parsing and setting

  for (const [key, descriptor] of Object.entries(OPTIONS)) {
    const values = allProvidedOptions.get(key);
    if (!values || values.length === 0) {
      if (DEFAULT_OPTIONS.has(key)) {
        setOption(mongoOptions, key, descriptor, [DEFAULT_OPTIONS.get(key)]);
      }
    } else {
      const { deprecated } = descriptor;
      if (deprecated) {
        const deprecatedMsg = typeof deprecated === 'string' ? `: ${deprecated}` : '';
        emitWarning(`${key} is a deprecated option${deprecatedMsg}`);
      }

View on GitHub (pinned to 3366c21a63)

Solutions

  1. Inspect the offending key name(s) in the error message and compare against the current MongoClientOptions type.
  2. Fix typos (e.g. maxPoolSzie -> maxPoolSize).
  3. Remove options that no longer exist; find the modern equivalent (e.g. bufferMaxEntries was removed; use maxPoolSize and handle errors).
  4. Run a typecheck (npm run check:ts) so TypeScript flags unknown options before runtime.

Example fix

// before
const c = new MongoClient(uri, { maxPoolSzie: 10, autoReconnect: true });
// after
const c = new MongoClient(uri, { maxPoolSize: 10 });
Defensive patterns

Strategy: type-guard

Type guard

import type { MongoClientOptions } from 'mongodb';
function isKnownOption(opts: unknown): opts is MongoClientOptions {
  // compile-time: excess-property checks on object literals surface unknown keys
  return typeof opts === 'object' && opts !== null;
}
// Rely on TS excess-property checks: declare the param as MongoClientOptions, not 'any'.

Try / catch

try { client = new MongoClient(uri, opts); }
catch (e) {
  if (e instanceof MongoParseError && /not supported/.test(e.message)) {
    const bad = e.message.match(/(?:option|options) (.+?) (?:is|are) not supported/)?.[1].split(', ') ?? [];
    bad.forEach(k => delete opts[k]);
    client = new MongoClient(uri, opts);
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a misspelled option like { maxPoolSzie: 10 }, a removed option like { autoReconnect: true }, or a URI param like '?bufferMaxEntries=5'. Any single unsupported key triggers it; multiple produce 'options X, Y are not supported'.

Common situations: Copy-pasting options from old tutorials or other drivers (e.g. mongoose-only keys); typos in option names; upgrading the driver and using options removed in v4/v5 (autoReconnect, bufferMaxEntries, reconnectInterval).

Related errors


AI-assisted analysis of mongodb/node-mongodb-native@3366c21a63 (2026-08-04). Data as JSON: /data/errors/ef5538d05458d5d8.json. Report an issue: GitHub.