AsyncLocalStorage store cleanup callback #57010
Labels
async_local_storage
AsyncLocalStorage
feature request
Issues that request new features to be added to Node.js.
What is the problem this feature will solve?
Currently I would like to store in
AsyncLocalStorage
an object that requires clean up. It is a MongoDB session, after the async chain is finished I should executesession.endSession
. I have no way to listen when the AsyncLocalStorage is going to be destroyed and execute my clean operation.What is the feature you are proposing to solve the problem?
I propose the adding a callback argument to the
AsyncLocalStorage.run
function to be executed at the end of the async chain started there.What alternatives have you considered?
I've tried using AsyncHooks to try to achieve this but I've unable to achieve this reliably.
The text was updated successfully, but these errors were encountered: