mongodb/node-mongodb-native · warning · MongoParseError

Unable to make a writeConcern from journal=

Error message

Unable to make a writeConcern from journal=${value}

What it means

`j` is a deprecated alias for `journal` (descriptor: `deprecated: 'Please use journal instead'`). The transform at src/connection_string.ts:860 builds a WriteConcern from `{...options.writeConcern, journal: getBoolean(name, value)}`; if WriteConcern.fromOptions returns falsy, MongoParseError is thrown at src/connection_string.ts:867. getBoolean rejects non-boolean values first.

Solutions

  1. Use `journal: true` (the canonical name) instead of `j: true`.
  2. Consolidate into one `writeConcern: { w: 'majority', journal: true }` object.
  3. Verify the merged options object still contains a valid w/journal/wtimeoutMS combination before construction.

Example fix

// before
new MongoClient(uri, { j: true });

// after
new MongoClient(uri, { journal: true });
Defensive patterns

Strategy: validation

Validate before calling

if ('j' in opts) {
  console.warn('j is deprecated; use journal instead');
  opts.journal = Boolean((opts as any).j);
  delete (opts as any).j;
}

Type guard

null

Try / catch

try { client = new MongoClient(uri, opts); } catch (e) { if (e instanceof MongoParseError && /journal/.test(e.message)) { opts.journal = (opts as any).j; delete (opts as any).j; client = new MongoClient(uri, opts); } else throw e; }

Prevention

When it happens

Trigger: Passing `j: true` in a writeConcern combination that yields no usable WriteConcern object; or routing `j` through config tooling that drops the sibling writeConcern fields needed by fromOptions.

Common situations: Using the short `j` alias from older tutorials; layering `j` on top of an existing `writeConcern` object whose keys conflict; partial config merging that leaves fromOptions nothing to build.

Related errors


AI-assisted analysis of mongodb/node-mongodb-native@dce7939f86 (2026-08-11). Data as JSON: /api/errors/ef9ae3cf90144368. Report an issue: GitHub.

Appendix: source

Thrown at src/connection_string.ts:867

  } as OptionDescriptor,
  heartbeatFrequencyMS: {
    default: 10000,
    type: 'uint'
  },
  ignoreUndefined: {
    type: 'boolean'
  },
  j: {
    deprecated: 'Please use journal instead',
    target: 'writeConcern',
    transform({ name, options, values: [value] }): WriteConcern {
      const wc = WriteConcern.fromOptions({
        writeConcern: {
          ...options.writeConcern,
          journal: getBoolean(name, value)
        }
      });
      if (!wc) throw new MongoParseError(`Unable to make a writeConcern from journal=${value}`);
      return wc;
    }
  } as OptionDescriptor,
  journal: {
    target: 'writeConcern',
    transform({ name, options, values: [value] }): WriteConcern {
      const wc = WriteConcern.fromOptions({
        writeConcern: {
          ...options.writeConcern,
          journal: getBoolean(name, value)
        }
      });
      if (!wc) throw new MongoParseError(`Unable to make a writeConcern from journal=${value}`);
      return wc;
    }
  },
  loadBalanced: {
    default: false,

View on GitHub (pinned to dce7939f86)