-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Open
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version
16.13.0
Platform
Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64
Subsystem
streams
What steps will reproduce the bug?
const readStream = fs.createReadStream(<a folder>)
const writeStream = fs.createWriteStream("foo.txt")
readStream.on("error", (error) => {
throw new errlop('Caught the error', error)'
})
readStream.pipe(writeStream);
await stream.finished(writeStream);
How often does it reproduce? Is there a required condition?
Always reproduces
What is the expected behavior?
await stream.finished(writeStream) returns the cleanup function specified at https://nodejs.org/docs/latest-v16.x/api/stream.html#streamfinishedstream-options-callback so we can clean up the error call.
Or that error rejects the promise we're awaiting on and gets treated as part of the normal Promise error handling flow.
What do you see instead?
"Uncaught Error: Caught the error"
Additional information
https://github.com/nodejs/node/blob/master/lib/internal/streams/end-of-stream.js#L242 drops the cleanup function that eos
returns.
I think I can work around this by manually making my own promises that resolve/reject based on callbacks firing
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.