mongodb/node-mongodb-native · error · MongoInvalidArgumentError
Cannot request unacknowledged write concern and verbose…
Error message
Cannot request unacknowledged write concern and verbose results
What it means
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.
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.
Example fix
// before
await client.bulkWrite(models, {
writeConcern: { w: 0 },
verboseResults: true
});
// after
await client.bulkWrite(models, {
writeConcern: { w: 1 },
verboseResults: true
}); Defensive patterns
Strategy: validation
Validate before calling
if (options?.writeConcern?.w === 0 && options?.verboseResults) {
throw new Error('Cannot combine w:0 with verboseResults');
}
await client.bulkWrite(models, options); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Performance tuning that sets w:0 globally and then turns on verboseResults for debugging; copy-pasting options between calls without reconciling them.
Related errors
- Cannot request unacknowledged write concern and ordered…
- write operation failed
- Argument "operations" must be an array of documents
- authMechanism not supported
- Bulk find operation must specify a selector
AI-assisted analysis of mongodb/node-mongodb-native@dce7939f86 (2026-08-11).
Data as JSON: /api/errors/69fb5d3348057d0b.
Report an issue: GitHub.
Appendix: source
Thrown at src/operations/client_bulk_write/executor.ts:64
}
this.client = client;
this.operations = operations;
this.options = {
ordered: true,
bypassDocumentValidation: false,
verboseResults: false,
...options
};
// If no write concern was provided, we inherit one from the client.
if (!this.options.writeConcern) {
this.options.writeConcern = WriteConcern.fromOptions(this.client.s.options);
}
if (this.options.writeConcern?.w === 0) {
if (this.options.verboseResults) {
throw new MongoInvalidArgumentError(
'Cannot request unacknowledged write concern and verbose results'
);
}
if (this.options.ordered) {
throw new MongoInvalidArgumentError(
'Cannot request unacknowledged write concern and ordered writes'
);
}
}
}
/**
* Execute the client bulk write. Will split commands into batches and exhaust the cursors
* for each, then merge the results into one.
* @returns The result.
*/
async execute(): Promise<ClientBulkWriteResult> {View on GitHub (pinned to dce7939f86)