forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: swallow stdout/stderr error events
This is a step in making `console` safe, swallows EPIPE and other errors by registering an empty 'error' event listener. Also fixes writes to stdout/stderr not working after `end()` is called, even though we already override `destroy()` so the stream is never actually closed. Refs: nodejs#831 Fixes: nodejs#947 Fixes: nodejs#9403
- Loading branch information
1 parent
690bded
commit 373402f
Showing
4 changed files
with
46 additions
and
13 deletions.
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
File renamed without changes.
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 |
---|---|---|
@@ -1,14 +1,9 @@ | ||
'use strict'; | ||
require('../common'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const shouldThrow = function() { | ||
process.stdout.end(); | ||
}; | ||
|
||
const validateError = function(e) { | ||
return e instanceof Error && | ||
e.message === 'process.stdout cannot be closed.'; | ||
}; | ||
|
||
assert.throws(shouldThrow, validateError); | ||
process.stdout.on('error', common.mustCall(function(e) { | ||
assert(e instanceof Error, 'e is an Error'); | ||
assert.strictEqual(e.message, 'process.stdout cannot be closed.'); | ||
})); | ||
process.stdout.end(); |