Skip to content

Commit b2f0ec4

Browse files
committed
fix: move session support check to operation layer
Monitor checks run on a timer and network errors cause a reset of the topology that would be corrected in the next cycle of the monitor, we were checking a property that gets updated by this async work. By moving the check to the operations layer we will allow users to obtain a session regardless of support and then emit an error if there is not support when the session is used in an operation. NODE-3100
1 parent d67ffa7 commit b2f0ec4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/mongo_client.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,6 @@ MongoClient.prototype.startSession = function(options) {
457457
throw new MongoError('Must connect to a server before calling this method');
458458
}
459459

460-
if (!this.topology.hasSessionSupport()) {
461-
throw new MongoError('Current topology does not support sessions');
462-
}
463-
464460
return this.topology.startSession(options, this.s.options);
465461
};
466462

lib/operations/execute_operation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ function executeOperation(topology, operation, callback) {
4747
} else if (operation.session.hasEnded) {
4848
throw new MongoError('Use of expired sessions is not permitted');
4949
}
50+
} else if (operation.session && operation.session.explicit) {
51+
throw new MongoError('Current topology does not support sessions');
5052
}
5153

5254
let result;

0 commit comments

Comments
 (0)