-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: make stdout and stderr emit 'close' on destroy
Fix: #26550 PR-URL: #26691 Fixes: https://github.com/false Fixes: #26550 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
274b97c
commit f34bb96
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Transform, Readable, pipeline } = require('stream'); | ||
const assert = require('assert'); | ||
|
||
const reader = new Readable({ | ||
read(size) { this.push('foo'); } | ||
}); | ||
|
||
let count = 0; | ||
|
||
const err = new Error('this-error-gets-hidden'); | ||
|
||
const transform = new Transform({ | ||
transform(chunk, enc, cb) { | ||
if (count++ >= 5) | ||
this.emit('error', err); | ||
else | ||
cb(null, count.toString() + '\n'); | ||
} | ||
}); | ||
|
||
pipeline( | ||
reader, | ||
transform, | ||
process.stdout, | ||
common.mustCall((e) => { | ||
assert.strictEqual(e, err); | ||
}) | ||
); |