Skip to content

Commit b88c938

Browse files
committed
fix(txns): omit writeConcern when in a transaction
1 parent 5c2d12c commit b88c938

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,15 @@ function applyWriteConcern(target, sources, options) {
455455
const db = sources.db;
456456
const coll = sources.collection;
457457

458+
if (options.session && options.session.inTransaction()) {
459+
// writeConcern is not allowed within a multi-statement transaction
460+
if (target.writeConcern) {
461+
delete target.writeConcern;
462+
}
463+
464+
return target;
465+
}
466+
458467
// NOTE: there is probably a much better place for this
459468
if (db && db.s.options.retryWrites) {
460469
target.retryWrites = true;

0 commit comments

Comments
 (0)