Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5052

Closing change stream crashes the application

    • 3
    • 3
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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);
      

       

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            keijo.kapp@gmail.com Keijo Kapp
            Daria Pardue
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: