Bind AsyncResource on busboy close event to preserve async context#1358
Open
finnp wants to merge 2 commits intoexpressjs:mainfrom
Open
Bind AsyncResource on busboy close event to preserve async context#1358finnp wants to merge 2 commits intoexpressjs:mainfrom
finnp wants to merge 2 commits intoexpressjs:mainfrom
Conversation
Author
|
Also just added a test for this |
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
multerthe 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.bindto 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!