{"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":"error","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/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/connection_string.ts#L1198-L1234","documentation":"`wtimeout` (deprecated; use `wtimeoutMS`) routes through `WriteConcern.fromOptions` (src/connection_string.ts:1205-1217); if that returns null the transform throws 'Cannot make WriteConcern from wtimeout'. The same message is reused for the `wtimeoutMS` option at src/connection_string.ts:1229. Generally requires a malformed combination, e.g. a timeout with no valid `w`.","triggerScenarios":"Providing `wtimeout`/`wtimeoutMS` without a valid `w`; values that yield an empty/invalid write concern after merging.","commonSituations":"Setting only wtimeout without w; legacy configs that still use the deprecated `wtimeout`; copy-paste from old tutorials.","solutions":["Switch to `wtimeoutMS` (wtimeout is deprecated)","Pair wtimeoutMS with a `w` value: `{ w: 'majority', wtimeoutMS: 1000 }`","Remove wtimeout if a timeout is not needed"],"exampleFix":"// before\nnew MongoClient(uri, { wtimeout: 1000 });\n// after\nnew MongoClient(uri, { writeConcern: { w: 'majority', wtimeoutMS: 1000 } });","handlingStrategy":"validation","validationCode":"// wtimeout is deprecated; normalize to wtimeoutMS paired with w.\nif ('wtimeout' in options) {\n  const { wtimeout, ...rest } = options;\n  options = { ...rest, writeConcern: { ...(rest.writeConcern || {}), wtimeoutMS: wtimeout } };\n}","typeGuard":null,"tryCatchPattern":"try {\n  const client = new MongoClient(uri, options);\n} catch (e) {\n  if (e instanceof MongoParseError && /WriteConcern from wtimeout/.test(e.message)) {\n    // replace wtimeout with wtimeoutMS and a valid w, then retry\n  } else throw e;\n}","preventionTips":["Use wtimeoutMS, not the deprecated wtimeout","Always pair a timeout with a valid w (e.g. 'majority')","Express write concern as a single writeConcern object"],"tags":["write-concern","deprecated","configuration"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}