-
-
Notifications
You must be signed in to change notification settings - Fork 35.1k
Open
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version
v18.12.1 and 16.18.1 and 16.10
Platform
Darwin Razs-MBP 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
Subsystem
stream
What steps will reproduce the bug?
Tested on:
18.12.116.18.116.10.0
Functions that will be used in the examples
function getData() {
return Readable.from(['a', 'b', 'c', 'd']);
}
async function* stopAfterFirst(stream) {
for await (const chunk of stream) {
yield chunk;
return;
}
}
async function* justListen(stream) {
for await (const _ of stream) ;
}
function createLogPipelineResult(prefix) {
prefix = prefix ? `${prefix}: ` : '';
return function logPipelineResult(e) {
if(e) {
console.log(`${prefix}pipeline error`, e);
} else {
console.log(`${prefix}pipeline succeeded`)
}
}
}The following are the problematic cases:
function duplexAndNotLast() {
pipeline(
getData(),
Duplex.from(stopAfterFirst), // <- Wrapped with duplex
justListen,
createLogPipelineResult('duplexAndNotLast'),
).on('error', createLogPipelineResult('duplexAndNotLast on error'));
// Node 18.12.1:
// => duplexAndNotLast: pipeline error AbortError: The operation was aborted
// Node 16.18.1 and 16.10.0:
// => no log at all
}
function noDuplexAndNotLast() {
pipeline(
getData(),
stopAfterFirst, // <- Not wrapped with duplex
justListen,
createLogPipelineResult('noDuplexAndNotLast'),
).on('error', createLogPipelineResult('noDuplexAndNotLast on error'));
// Node 18.12.1:
// => noDuplexAndNotLast: pipeline succeeded
// Node 16.18.1 and 16.10.0:
// => noDuplexAndNotLast: pipeline error Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
}
function duplexAndLast() {
pipeline(
getData(),
Duplex.from(stopAfterFirst), // <- Wrapped with duplex and last
createLogPipelineResult('duplexAndLast'),
).on('error', createLogPipelineResult('duplexAndLast on error'));
// Node 18.12.1:
// not logging **at all**
// Node 16.18.1 and 16.10.0:
// not logging **at all**
}
function noDuplexAndLast() {
pipeline(
getData(),
stopAfterFirst, // <- Not wrapped with duplex and last
createLogPipelineResult('noDuplexAndLast'),
).on('error', createLogPipelineResult('noDuplexAndLast on error'));
// Node 18.12.1:
// => noDuplexAndLast: pipeline succeeded
// Node 16.18.1 and 16.10.0:
// => noDuplexAndLast: pipeline error Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
}How often does it reproduce? Is there a required condition?
every time
What is the expected behavior?
No response
What do you see instead?
added in each function in What steps will reproduce the bug?
Additional information
Maybe it's related to #44026
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.