{"record":{"id":"054f51e1c38aad2a","repo":"mongodb/node-mongodb-native","slug":"unable-to-make-a-writeconcern-from-fsync-value","errorCode":null,"errorMessage":"Unable to make a writeConcern from fsync=${value}","messagePattern":"Unable to make a writeConcern from fsync=(.+?)","errorType":"exception","errorClass":"MongoParseError","httpStatus":null,"severity":"warning","filePath":"src/connection_string.ts","lineNumber":846,"sourceCode":"  },\n  fieldsAsRaw: {\n    type: 'record'\n  },\n  forceServerObjectId: {\n    default: false,\n    type: 'boolean'\n  },\n  fsync: {\n    deprecated: 'Please use journal instead',\n    target: 'writeConcern',\n    transform({ name, options, values: [value] }): WriteConcern {\n      const wc = WriteConcern.fromOptions({\n        writeConcern: {\n          ...options.writeConcern,\n          fsync: getBoolean(name, value)\n        }\n      });\n      if (!wc) throw new MongoParseError(`Unable to make a writeConcern from fsync=${value}`);\n      return wc;\n    }\n  } as OptionDescriptor,\n  heartbeatFrequencyMS: {\n    default: 10000,\n    type: 'uint'\n  },\n  ignoreUndefined: {\n    type: 'boolean'\n  },\n  j: {\n    deprecated: 'Please use journal instead',\n    target: 'writeConcern',\n    transform({ name, options, values: [value] }): WriteConcern {\n      const wc = WriteConcern.fromOptions({\n        writeConcern: {\n          ...options.writeConcern,\n          journal: getBoolean(name, value)","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/connection_string.ts#L828-L864","documentation":"`fsync` is a deprecated write-concern option (the descriptor carries `deprecated: 'Please use journal instead'`). The transform at src/connection_string.ts:839 builds a WriteConcern via `WriteConcern.fromOptions`; if that returns a falsy value, the driver throws MongoParseError at src/connection_string.ts:846. The boolean coercion itself happens earlier via getBoolean, so a non-boolean fsync surfaces as a separate 'must be either true or false' error.","triggerScenarios":"Passing `fsync: true` together with other writeConcern fields in a combination that WriteConcern.fromOptions refuses to materialize; or wiring fsync through a config layer that strips sibling writeConcern fields. In practice this branch is rare because the boolean itself is already validated.","commonSituations":"Carrying forward v3-era option names; mixing `fsync` with a hand-built `writeConcern` object whose keys collide or cancel out; tooling that drops empty fields when merging config.","solutions":["Replace `fsync` with `journal: true` (the supported, non-deprecated equivalent).","Prefer a single `writeConcern: { w: 'majority', journal: true }` object instead of spreading concerns across options.","If you must use fsync, ensure the surrounding writeConcern fields are consistent and not stripped by config merging."],"exampleFix":"// before\nnew MongoClient(uri, { fsync: true });\n\n// after\nnew MongoClient(uri, { journal: true });","handlingStrategy":"validation","validationCode":"if ('fsync' in opts) {\n  console.warn('fsync is deprecated; use journal instead');\n  opts.journal = Boolean(opts.fsync);\n  delete opts.fsync;\n}","typeGuard":"null","tryCatchPattern":"try { client = new MongoClient(uri, opts); } catch (e) { if (e instanceof MongoParseError && /fsync/.test(e.message)) { opts.journal = (opts as any).fsync; delete (opts as any).fsync; client = new MongoClient(uri, opts); } else throw e; }","preventionTips":["Stop using fsync; prefer journal.","Consolidate write-concern fields into one `writeConcern` object.","Run an ESLint custom rule or grep for `fsync:` in your config layer."],"tags":["write-concern","deprecated","configuration"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}