{"record":{"id":"bb2ad7334110bc80","repo":"mongodb/node-mongodb-native","slug":"cannot-request-unacknowledged-write-concern-and-or","errorCode":null,"errorMessage":"Cannot request unacknowledged write concern and ordered writes","messagePattern":"Cannot request unacknowledged write concern and ordered writes","errorType":"exception","errorClass":"MongoInvalidArgumentError","httpStatus":null,"severity":"error","filePath":"src/operations/client_bulk_write/executor.ts","lineNumber":70,"sourceCode":"      bypassDocumentValidation: false,\n      verboseResults: false,\n      ...options\n    };\n\n    // If no write concern was provided, we inherit one from the client.\n    if (!this.options.writeConcern) {\n      this.options.writeConcern = WriteConcern.fromOptions(this.client.s.options);\n    }\n\n    if (this.options.writeConcern?.w === 0) {\n      if (this.options.verboseResults) {\n        throw new MongoInvalidArgumentError(\n          'Cannot request unacknowledged write concern and verbose results'\n        );\n      }\n\n      if (this.options.ordered) {\n        throw new MongoInvalidArgumentError(\n          'Cannot request unacknowledged write concern and ordered writes'\n        );\n      }\n    }\n  }\n\n  /**\n   * Execute the client bulk write. Will split commands into batches and exhaust the cursors\n   * for each, then merge the results into one.\n   * @returns The result.\n   */\n  async execute(): Promise<ClientBulkWriteResult> {\n    // The command builder will take the user provided models and potential split the batch\n    // into multiple commands due to size.\n    const pkFactory = this.client.s.options.pkFactory;\n    const commandBuilder = new ClientBulkWriteCommandBuilder(\n      this.operations,\n      this.options,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/operations/client_bulk_write/executor.ts#L52-L88","documentation":"Thrown when bulk write options combine writeConcern w:0 (unacknowledged) with ordered: true. Because ordered writes wait for each batch to be acknowledged before sending the next, ordering is meaningless without acknowledgements; the driver requires ordered: false when w is 0.","triggerScenarios":"Calling client.bulkWrite(models, { writeConcern: { w: 0 } }) without overriding ordered — the default for ordered is true, so the check fails immediately. Same outcome if you set both w:0 and ordered: true explicitly.","commonSituations":"Setting w=0 in the connection string for throughput and then calling bulkWrite without options; performance tuning that drops acknowledgement but forgets to relax ordering.","solutions":["Pair w:0 with ordered: false: client.bulkWrite(models, { writeConcern: { w: 0 }, ordered: false }).","Or keep ordered writes by using an acknowledged write concern (omit w:0).","Remember ordered defaults to true — you must explicitly opt out when w is 0."],"exampleFix":"// before\nawait client.bulkWrite(models, { writeConcern: { w: 0 } }); // ordered defaults to true\n\n// after\nawait client.bulkWrite(models, { writeConcern: { w: 0 }, ordered: false });","handlingStrategy":"validation","validationCode":"if (options?.writeConcern?.w === 0 && (options?.ordered ?? true)) {\n  throw new Error('w:0 requires ordered:false');\n}\nawait client.bulkWrite(models, { ...options, ordered: options?.writeConcern?.w === 0 ? false : (options?.ordered ?? true) });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whenever you set w=0 (in URI or options), set ordered:false in the same edit.","Audit connection strings for w=0 and review all bulkWrite call sites."],"tags":["bulk-write","write-concern","config"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}