-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- Version: 12.16.2, 13.12.0
- Platform: linux
- Subsystem: arch
What steps will reproduce the bug?
If synchronous generator wrapped with stream.Readable.from
emits rejected Promise
then finally blocks of that generator is never called.
But if that generator is consumed with general for-of
loop then finally
blocks are called as expected.
stream.Readable.from(function*() {
try {
yield Promise.resolve(1)
yield Promise.reject('error')
} finally {
console.log('fin')
}
}())
.on('data',x=>console.log(x))
.on('error',e=>console.log(e))
It logs
1
error
but does not log fin
.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
stream.Readable.from
should either not resolve Promise
s yielded from synchronous generators and should pass unresolved Promise
s to the returned stream or should properly close generator even if it yields rejected Promise
.
Additional information
To fix this there should be called iterator.return
if await value
throws.
node/lib/internal/streams/from.js
Line 57 in f21cf45
readable.destroy(err); |
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.