Skip to content

Bind AsyncResource on busboy close event to preserve async context #1358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

finnp
Copy link

@finnp finnp commented Aug 15, 2025

When using multer the Async Local Storage gets lost. This is because the busboys event handler runs next and after event handlers the async context gets lost in Node.js.

This was reported in #814 and #1111

I added a feature detect AsyncStroage.bind to make sure the context is not lost.

I tested this based on the the multer-test repository by @C-Saunders and it worked 👏

Let me know what you think!

@finnp finnp changed the title Bind AsyncResource on busboy close event to preserve async context, Fixes #814 and #1111 Bind AsyncResource on busboy close event to preserve async context Aug 15, 2025
@finnp
Copy link
Author

finnp commented Aug 15, 2025

Also just added a test for this

@finnp
Copy link
Author

finnp commented Aug 16, 2025

I realize there are other attempts already at fixing this. Didn't see them through the search, e.g.: #1124. Would be great to get one solution merged. The linked one here seems maybe a tat more defensive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant