{"record":{"id":"69fb5d3348057d0b","repo":"mongodb/node-mongodb-native","slug":"cannot-request-unacknowledged-write-concern-and-ve","errorCode":null,"errorMessage":"Cannot request unacknowledged write concern and verbose results","messagePattern":"Cannot request unacknowledged write concern and verbose results","errorType":"exception","errorClass":"MongoInvalidArgumentError","httpStatus":null,"severity":"error","filePath":"src/operations/client_bulk_write/executor.ts","lineNumber":64,"sourceCode":"    }\n\n    this.client = client;\n    this.operations = operations;\n    this.options = {\n      ordered: true,\n      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> {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/operations/client_bulk_write/executor.ts#L46-L82","documentation":"Thrown when bulk write options request writeConcern w:0 (unacknowledged) together with verboseResults: true. Unacknowledged writes do not return per-operation results, so requesting verbose detail is contradictory and the driver rejects it up front rather than silently dropping data.","triggerScenarios":"Calling client.bulkWrite(models, { writeConcern: { w: 0 }, verboseResults: true }). Also when w:0 is inherited from the connection string or client options and verboseResults is explicitly enabled on the call.","commonSituations":"Performance tuning that sets w:0 globally and then turns on verboseResults for debugging; copy-pasting options between calls without reconciling them.","solutions":["If you need verbose results, use an acknowledged write concern (omit w:0 or set w:1/majority).","If you need fire-and-forget throughput, drop verboseResults: false (or omit it).","Audit writeConcern inheritance — connection-string w=0 propagates to all bulkWrite calls unless overridden."],"exampleFix":"// before\nawait client.bulkWrite(models, {\n  writeConcern: { w: 0 },\n  verboseResults: true\n});\n\n// after\nawait client.bulkWrite(models, {\n  writeConcern: { w: 1 },\n  verboseResults: true\n});","handlingStrategy":"validation","validationCode":"if (options?.writeConcern?.w === 0 && options?.verboseResults) {\n  throw new Error('Cannot combine w:0 with verboseResults');\n}\nawait client.bulkWrite(models, options);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat w:0 as fire-and-forget — never pair it with options that expect results.","Document the writeConcern contract for any global default you set."],"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"}