Skip to content

AsyncLocalStorage store cleanup callback #57010

Open
@eliocapella

Description

@eliocapella

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 execute session.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_local_storageAsyncLocalStoragefeature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions