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
Since this method is asynchroneous and it is not waited for its completion, the following error is thrown when the close() method is called immediately afterwards because the index creation is still running in the background.
(node:27307) UnhandledPromiseRejectionWarning: MongoError: Cannot use a session that has ended
Calling close() immediately after creating the session store is a valid behaviour when somewhere in the following startup process of the server a critical error occurs and the server should shutdown gracefully. This currently doesn't work due to the error. The same behaviour probably applies when autoRemove is set to interval because there the deleteMany() method is called without waiting for its completion.
Either making the whole creation process asynchroneous or emitting an event once the various asynchroneous calls have finished would solve the problem.
The text was updated successfully, but these errors were encountered:
That would be possible. But I think this either needs a fix or a warning in the README. This problem is not trivial and took me some time to understand where this bug is coming from. Calling two valid methods of an SDK shouldn't result in an error. So I think this needs at least a warning.
When having the
autoRemove
function set tonative
, connect-mongo starts creating an index.collection.createIndex({ expires: 1 }, { expireAfterSeconds: 0, ...this.options.writeOperationOptions });
Since this method is asynchroneous and it is not waited for its completion, the following error is thrown when the
close()
method is called immediately afterwards because the index creation is still running in the background.(node:27307) UnhandledPromiseRejectionWarning: MongoError: Cannot use a session that has ended
Calling
close()
immediately after creating the session store is a valid behaviour when somewhere in the following startup process of the server a critical error occurs and the server should shutdown gracefully. This currently doesn't work due to the error. The same behaviour probably applies whenautoRemove
is set tointerval
because there thedeleteMany()
method is called without waiting for its completion.Either making the whole creation process asynchroneous or emitting an event once the various asynchroneous calls have finished would solve the problem.
The text was updated successfully, but these errors were encountered: