Repository navigation
fix: construct stream errors without new - #561
Open
joshbarros wants to merge 2 commits into
Open
joshbarros wants to merge 2 commits into
joshbarros wants to merge 2 commits into
Conversation
Node 18's vendored _final calls ERR_MULTIPLE_CALLBACK() with no new. The class throws TypeError before the constructor body. A second synchronous callback emits that TypeError. A second callback on nextTick escapes as an uncaught exception. write() already uses new and emits ERR_MULTIPLE_CALLBACK. The factory returns the same instance with or without new. The vendored writable.js stays the Node 18.19.0 copy. Signed-off-by: Josue Barros <joshbarrosweb@gmail.com>
Author
|
Hi! The new commit needs workflow approval before CI can run. Could you approve the runs when you have a moment? Thanks! |
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.
_finalcallsERR_MULTIPLE_CALLBACK()with nonew.E()exports a class, so that call throwsTypeError: Class constructor NodeError cannot be invoked without 'new'before the constructor body runs.A second synchronous callback emits that
TypeErroronerror, with nocode. A second callback onnextTickthrows outside thetryaround_final, and the process exits.write()already usesnewand emitsERR_MULTIPLE_CALLBACK.Node fixed the call site in nodejs/node#52110. This package is the Node 18.19.0 cut, so
lib/internal/streams/writable.jsstays that copy. The factory inours/errors.jsreturns the same instance with or withoutnew.instanceof,name,codeand the message stay the same.On Node v22.19.0, from
ffeeda66:_finalcallback emittedTypeErrorwith nocode. It now emitsERR_MULTIPLE_CALLBACK, matchingnode:stream._finalcallback onnextTickexited 1. It no longer throws.finishhas already destroyed the stream, so no second error is emitted.node:streamon Node 22 does the same.writecallback still emitsERR_MULTIPLE_CALLBACK.npm testpassed 191 files.npx eslinton the touchedsrcfiles was clean.npx prettier -con the six files was clean.Fixes #532