-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
7f3c29c
commit 80337a8
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); | ||
}) | ||
); |