{"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":"error","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/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/connection_string.ts#L828-L864","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Copying old config that still references fsync; mixing fsync with conflicting write concern options; legacy code paths.","solutions":["Replace `fsync` with `journal: true` (the documented replacement)","Remove `fsync` entirely if you don't need hard-durability pinning","Pass write concern explicitly as `{ w: 'majority', j: true }`"],"exampleFix":"// before\nnew MongoClient(uri, { fsync: true });\n// after\nnew MongoClient(uri, { journal: true });","handlingStrategy":"validation","validationCode":"// fsync is deprecated; prefer journal. Validate before constructing:\nif ('fsync' in options || 'j' in options) {\n  console.warn('fsync/j are deprecated; use journal instead');\n  const { fsync, j, ...rest } = options;\n  options = { ...rest, journal: fsync ?? j };\n}","typeGuard":null,"tryCatchPattern":"try {\n  const client = new MongoClient(uri, options);\n} catch (e) {\n  if (e instanceof MongoParseError && /writeConcern from fsync/.test(e.message)) {\n    // replace fsync with journal and retry\n  } else throw e;\n}","preventionTips":["Stop using fsync; use journal","Express write concern as a single writeConcern object","Audit legacy configs for deprecated write-concern fields"],"tags":["write-concern","deprecated","configuration"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}