You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.9.x
Node.js version
22.x
MongoDB server version
7
Typescript version (if applicable)
No response
Description
When using Model.collection.findOne.populate(....) the Driver shutdown the session that running and end up with MongoExpiredSessionError: Cannot use a session that has ended
here's the full exception:
MongoExpiredSessionError: Cannot use a session that has ended
at applySession (node_modules/mongodb/src/sessions.ts:1101:12)
at Connection.prepareCommand (node_modules/mongodb/src/cmap/connection.ts:380:40)
at Connection.sendCommand (node_modules/mongodb/src/cmap/connection.ts:498:26)
at sendCommand.next (<anonymous>)
at Connection.command (node_modules/mongodb/src/cmap/connection.ts:617:22)
at Server.command (node_modules/mongodb/src/sdam/server.ts:337:32)
at FindOperation.execute (node_modules/mongodb/src/operations/find.ts:130:12)
at tryOperation (node_modules/mongodb/src/operations/execute_operation.ts:278:14)
at executeOperation (node_modules/mongodb/src/operations/execute_operation.ts:112:12)
at FindCursor._initialize (node_modules/mongodb/src/cursor/find_cursor.ts:90:22)
at FindCursor.cursorInit (node_modules/mongodb/src/cursor/abstract_cursor.ts:896:21)
at FindCursor.fetchBatch (node_modules/mongodb/src/cursor/abstract_cursor.ts:934:7)
at FindCursor.next (node_modules/mongodb/src/cursor/abstract_cursor.ts:569:9)
at Collection.findOne (node_modules/mongodb/src/collection.ts:524:17)
Don't know if it's possible to use .populate with .collection methods or not, but the error is not an obvious one and should be more clear
Steps to Reproduce
Say we have a collection named Schools and another one named Classes
Prerequisites
Mongoose version
8.9.x
Node.js version
22.x
MongoDB server version
7
Typescript version (if applicable)
No response
Description
When using Model.collection.findOne.populate(....) the Driver shutdown the session that running and end up with
MongoExpiredSessionError: Cannot use a session that has ended
here's the full exception:
Don't know if it's possible to use .populate with .collection methods or not, but the error is not an obvious one and should be more clear
Steps to Reproduce
Say we have a collection named
Schools
and another one namedClasses
the exception will occur
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: