-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Open
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version: 14.4.0
Platform: 64-bit (Windows)
Subsystem: stream
pipeline
throws Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
when:
- There is a destination function and transformer function throws from
for await
block .
// Expecting: Error: transformer
// Got: Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
Stream.pipeline(
Stream.Readable.from(['a', 'b', 'c']),
async function* (readable) {
for await (const chunk of readable) {
// If this line is moved before or after the `for await` a correct error is thrown
throw new Error('transformer');
}
},
// If destination function is removed a correct error is thrown
async function (readable) {
let result = '';
for await (const chunk of readable) {
result += chunk;
}
return result;
},
(error, val) => error ? console.error(error) : console.log(val)
)
- The destination function throws from
for await
block
// Expecting: Error: destination
// Got: Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
Stream.pipeline(
Stream.Readable.from(['a', 'b', 'c']),
async function (readable) {
let result = '';
for await (const chunk of readable) {
// If this line is moved before or after the `for await` a correct error is thrown
throw new Error('destination');
result += chunk;
}
return result;
},
(error, val) => error ? console.error(error) : console.log(val)
)
- The transformer or destination
return
s fromfor await
block
// Expecting: Pipeline resolved with the value returned from destination and unfinished streams being silently destroyed
// Got: Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
Stream.pipeline(
Stream.Readable.from(['a', 'b', 'c']),
async function (readable) {
for await (const chunk of readable) {
// If this line is moved BEFORE `for await` - callback is NOT called AT ALL (node simply exits if it has nothing else to do)
return 'foo';
}
},
(error, val) => error ? console.error(error) : console.log(val)
)
timoxley, lili21, rluvaton and adamdbradley
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.