-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream.pipeline doesn't report failures if process.stdout is in the pipeline. #26550
Comments
you can handle the error by yourself to fix it const { Transform, Readable, pipeline } = require('stream')
const reader = new Readable({
read (size) {
this.push('foo')
}
})
let count = 0
const transform = new Transform({
transform (chunk, enc, cb) {
if (count++ >= 5) {
this.emit('error', new Error('this-error-gets-hidden'))
} else {
cb(null, count.toString() + '\n')
}
}
})
// handle it
transform.on('error', (e) => {
console.log(e)
})
pipeline(
reader,
transform,
process.stdout,
e => e ? console.error(e) : console.log('done')
) |
I found that Lines 715 to 721 in 6e81a95
|
node/lib/internal/streams/end-of-stream.js Lines 52 to 54 in 6e81a95
I speculate errorOrDestroy() is never actually called.
|
I don't think this is a bug in node/lib/internal/fs/sync_write_stream.js Lines 27 to 36 in 6f77af5
cc @tadjik1 |
@mcollina my PR fixes this problem as well:
note: I'm not using |
Here is a fix for this specific issue: #26691. The problem was caused by |
Fix: nodejs#26550 PR-URL: nodejs#26691 Fixes: https://github.com/false Fixes: nodejs#26550 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fix: #26550 PR-URL: #26691 Fixes: https://github.com/false Fixes: #26550 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fix: #26550 PR-URL: #26691 Fixes: https://github.com/false Fixes: #26550 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fix: #26550 PR-URL: #26691 Fixes: https://github.com/false Fixes: #26550 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Doesn't seem to be fixed using the following versions:
As a workaround I used this:
The Is it just a matter of delay between fix and stable version? |
I think it's a separate bug, because the script at the top reports the error on both 10.16.3 and 12.11, but it does not on 10.16.0. Can you open a new issue with a full script to reproduce? |
1 similar comment
I think it's a separate bug, because the script at the top reports the error on both 10.16.3 and 12.11, but it does not on 10.16.0. Can you open a new issue with a full script to reproduce? |
On the other hand, maybe the default of trying to close the last stream is OK, and for those specials cases (like stdout) where its not desirable, the workaround is pretty simple. |
I do not think I can help without a full repro of the problem you are experiencing. Can you open a new issue with a way to reproduce and tag me? Thanks |
Below is a simple example of a pipeline starting with a Readable, Transform, and then process.stdout. Failures in the Transform do not get reported by Stream.pipeline.
The error that is emitted never shows up in the pipeline's callback. The pipeline does stop on the 5th iteration as expected, but the error gets gobbled up somehow. If process.stdout is removed from the pipeline, the error is displayed as expected.
Interestingly, the following works as expected:
The text was updated successfully, but these errors were encountered: