diff --git a/lib/core/sessions.js b/lib/core/sessions.js index ff5268039d..672c8082ec 100644 --- a/lib/core/sessions.js +++ b/lib/core/sessions.js @@ -661,7 +661,12 @@ function commandSupportsReadConcern(command, options) { return true; } - if (command.mapReduce && options.out && (options.out.inline === 1 || options.out === 'inline')) { + if ( + command.mapReduce && + options && + options.out && + (options.out.inline === 1 || options.out === 'inline') + ) { return true; } @@ -692,7 +697,7 @@ function applySession(session, command, options) { // first apply non-transaction-specific sessions data const inTransaction = session.inTransaction() || isTransactionCommand(command); const isRetryableWrite = options.willRetryWrite; - const shouldApplyReadConcern = commandSupportsReadConcern(command); + const shouldApplyReadConcern = commandSupportsReadConcern(command, options); if (serverSession.txnNumber && (isRetryableWrite || inTransaction)) { command.txnNumber = BSON.Long.fromNumber(serverSession.txnNumber);