-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 5.0.0, 5.0.1
-
Component/s: Change Streams
After upgrading MongoDB driver from v4.13.0 to v5.0.x, closing the change stream (script below) crashes the application with the following output:
/project-path/node_modules/mongodb/lib/operations/execute_operation.js:50 throw new error_1.MongoExpiredSessionError('Use of expired sessions is not permitted'); ^ MongoExpiredSessionError: Use of expired sessions is not permitted at executeOperationAsync (/project-path/node_modules/mongodb/lib/operations/execute_operation.js:50:19) at /project-path/node_modules/mongodb/lib/operations/execute_operation.js:12:45 at maybeCallback (/project-path/node_modules/mongodb/lib/utils.js:288:21) at executeOperation (/project-path/node_modules/mongodb/lib/operations/execute_operation.js:12:38) at cleanupCursor (/project-path/node_modules/mongodb/lib/cursor/abstract_cursor.js:596:46) at node:internal/util:377:7 at new Promise (<anonymous>) at cleanupCursor (node:internal/util:363:12) at ChangeStreamCursor.close (/project-path/node_modules/mongodb/lib/cursor/abstract_cursor.js:255:15) at ReadableCursorStream._destroy (/project-path/node_modules/mongodb/lib/cursor/abstract_cursor.js:626:22) { [Symbol(errorLabels)]: Set(0) {} } Node.js v19.5.0
Node.js version: 19.5.0
MongoDB driver version: 5.0.1
MongoDB server version: 6.0.4
MongoDB cluster type: Replica Set
Script to reproduce:
import mongodb from 'mongodb'; const changeStream = new mongodb.MongoClient('<URL>').db().collection('asdasd').watch(); changeStream.on('change', console.dir); setTimeout(() => { changeStream.close(); }, 1000);
- is depended on by
-
MONGOSH-1358 Update to driver and bson v5.x
- Closed
- is duplicated by
-
NODE-5060 ChangeStream - Use of expired sessions is not permitted
- Closed
- is related to
-
NODE-4996 maybeCallback rejects with an unhandledRejection instead of uncaught exceptions
- Closed