-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version
17.x, 18.x, 19.x
Platform
Darwin watson.localdomain 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64
Subsystem
stream
What steps will reproduce the bug?
On Node.js 17 and newer, the program below will call the finished
callback with an ERR_STREAM_PREMATURE_CLOSE
error.
const { Duplex, finished } = require('stream');
const stream = new Duplex({
write (chunk, enc, cb) {
setImmediate(cb);
}
});
stream.end('foo');
finished(stream, { readable: false }, (err) => {
console.log('Finished!', { err });
});
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
I'm not sure. For me it's unexpected and I'm not sure how to use finished
in a scenario like this without getting this error.
What do you see instead?
I would expect the finished
callback to be called without an error.
Additional information
As mentioned above, I'm not 100% if this is a bug or not. If it's not a bug, then the behaviour is at least unexpected and finished
probably needs better documentation.
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.