fix: node 16 passthrough multiple callback error#88
Merged
kylefarris merged 2 commits intokylefarris:masterfrom Feb 17, 2022
Merged
fix: node 16 passthrough multiple callback error#88kylefarris merged 2 commits intokylefarris:masterfrom
kylefarris merged 2 commits intokylefarris:masterfrom
Conversation
Owner
|
Thanks for the PR! I'm reviewing and testing it now. |
Owner
|
Hey man, very thorough explanation. You had to dive deep into this issue to understand it and I really appreciate the help! All the tests have passed--everything looks good. I'm going to merge this as soon as I add you as a contributor. |
kylefarris
approved these changes
Feb 17, 2022
Owner
|
New version: 2.0.2 has been pushed to NPM. |
Contributor
Author
|
Thanks for the quick review and release! |
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.
Node 16 includes a behavior change that breaks many stream implementation functions if they use async/await syntax. Async functions implicitly return a Promise, and node's stream internals automatically call the underlying callback if the function's result is a thenable. There is some logic to skip the automatic callback if it was already called explicitly in the function; however, this can execute before other asynchronous tasks, which results in a
ERR_MULTIPLE_CALLBACKerror when the explicit callback is invoked. For example, the callback in thisdrainevent handler will often trigger the error:This new behavior for thenables is undocumented and has already been deprecated. Unfortunately, we need to live with it for now. The most straightforward solution is to use a Promise chain instead of async/await in NodeClam
passthrough()'sTransformimplementation.This PR also makes a change to use
stream.Readablein jsdoc instead ofReadableStreamfrom the experimental Web Streams API. (Complementary types change in DefinitelyTyped/DefinitelyTyped#58698.)Fixes #82
Refs nodejs/node#39535, nodejs/node#40773