mongodb/node-mongodb-native · error · MongoParseError

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

Error message

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

What it means

`fsync` is a deprecated write-concern option (use `journal` instead). Its transform (src/connection_string.ts:836-848) calls `WriteConcern.fromOptions`; if that returns null (cannot form a valid WriteConcern from the merged options), it throws. Reachable when the resulting write concern is empty/invalid after merging.

Source

Thrown at src/connection_string.ts:846

  },
  fieldsAsRaw: {
    type: 'record'
  },
  forceServerObjectId: {
    default: false,
    type: 'boolean'
  },
  fsync: {
    deprecated: 'Please use journal instead',
    target: 'writeConcern',
    transform({ name, options, values: [value] }): WriteConcern {
      const wc = WriteConcern.fromOptions({
        writeConcern: {
          ...options.writeConcern,
          fsync: getBoolean(name, value)
        }
      });
      if (!wc) throw new MongoParseError(`Unable to make a writeConcern from fsync=${value}`);
      return wc;
    }
  } 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)

View on GitHub (pinned to 3366c21a63)

Solutions

  1. Replace `fsync` with `journal: true` (the documented replacement)
  2. Remove `fsync` entirely if you don't need hard-durability pinning
  3. Pass write concern explicitly as `{ w: 'majority', j: true }`

Example fix

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

Strategy: validation

Validate before calling

// fsync is deprecated; prefer journal. Validate before constructing:
if ('fsync' in options || 'j' in options) {
  console.warn('fsync/j are deprecated; use journal instead');
  const { fsync, j, ...rest } = options;
  options = { ...rest, journal: fsync ?? j };
}

Try / catch

try {
  const client = new MongoClient(uri, options);
} catch (e) {
  if (e instanceof MongoParseError && /writeConcern from fsync/.test(e.message)) {
    // replace fsync with journal and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Providing `fsync` in a context where no usable write concern can be derived (e.g. conflicting/empty write concern state); generally rare — fromOptions returns null only for malformed combinations.

Common situations: Copying old config that still references fsync; mixing fsync with conflicting write concern options; legacy code paths.

Related errors


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