{"record":{"id":"96e7c2d537f746b5","repo":"mongodb/node-mongodb-native","slug":"cannot-make-writeconcern-from-wtimeout","errorCode":null,"errorMessage":"Cannot make WriteConcern from wtimeout","messagePattern":"Cannot make WriteConcern from wtimeout","errorType":"exception","errorClass":"MongoParseError","httpStatus":null,"severity":"warning","filePath":"src/connection_string.ts","lineNumber":1216,"sourceCode":"          }\n        });\n      }\n\n      throw new MongoParseError(`Invalid WriteConcern cannot parse: ${JSON.stringify(value)}`);\n    }\n  },\n  wtimeout: {\n    deprecated: 'Please use wtimeoutMS instead',\n    target: 'writeConcern',\n    transform({ values: [value], options }) {\n      const wc = WriteConcern.fromOptions({\n        writeConcern: {\n          ...options.writeConcern,\n          wtimeout: getUIntFromOptions('wtimeout', value)\n        }\n      });\n      if (wc) return wc;\n      throw new MongoParseError(`Cannot make WriteConcern from wtimeout`);\n    }\n  } as OptionDescriptor,\n  wtimeoutMS: {\n    target: 'writeConcern',\n    transform({ values: [value], options }) {\n      const wc = WriteConcern.fromOptions({\n        writeConcern: {\n          ...options.writeConcern,\n          wtimeoutMS: getUIntFromOptions('wtimeoutMS', value)\n        }\n      });\n      if (wc) return wc;\n      throw new MongoParseError(`Cannot make WriteConcern from wtimeout`);\n    }\n  },\n  zlibCompressionLevel: {\n    default: 0,\n    type: 'int'","sourceCodeStart":1198,"sourceCodeEnd":1234,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/connection_string.ts#L1198-L1234","documentation":"`wtimeout` is a deprecated write-concern option (descriptor: `deprecated: 'Please use wtimeoutMS instead'`). The transform at src/connection_string.ts:1208 builds a WriteConcern from `{...options.writeConcern, wtimeout: getUIntFromOptions('wtimeout', value)}`; if fromOptions returns falsy, MongoParseError is thrown at src/connection_string.ts:1216. Non-uint values fail earlier inside getUIntFromOptions.","triggerScenarios":"Passing `wtimeout: 1000` while the surrounding writeConcern fields leave fromOptions with nothing valid to build; layering `wtimeout` over a writeConcern object whose `w` field was removed.","commonSituations":"Carrying forward v3-era option names; config merge layers that strip `w`; using wtimeout without also specifying a replication factor.","solutions":["Use `wtimeoutMS` (the canonical name) instead of `wtimeout`.","Pair it with a valid `w`, e.g. `writeConcern: { w: 'majority', wtimeoutMS: 1000 }`.","Audit config merging so `w` is not deleted alongside wtimeout."],"exampleFix":"// before\nnew MongoClient(uri, { wtimeout: 1000 });\n\n// after\nnew MongoClient(uri, { writeConcern: { w: 'majority', wtimeoutMS: 1000 } });","handlingStrategy":"validation","validationCode":"if ('wtimeout' in (opts as any)) {\n  console.warn('wtimeout is deprecated; use wtimeoutMS');\n  const ms = Number((opts as any).wtimeout);\n  delete (opts as any).wtimeout;\n  opts.writeConcern = { ...(opts.writeConcern as any), wtimeoutMS: ms };\n}","typeGuard":"null","tryCatchPattern":"try { client = new MongoClient(uri, opts); } catch (e) { if (e instanceof MongoParseError && /wtimeout/.test(e.message)) { const ms = (opts as any).wtimeout; delete (opts as any).wtimeout; opts.writeConcern = { w: 'majority', wtimeoutMS: ms }; client = new MongoClient(uri, opts); } else throw e; }","preventionTips":["Migrate config from `wtimeout` to `wtimeoutMS`.","Always pair the timeout with an explicit `w`.","Grep the codebase for the deprecated name during upgrades."],"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"}