summaryrefslogtreecommitdiff
path: root/test/fixtures
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-01-26 17:14:16 -0800
committerisaacs <i@izs.me>2012-01-26 17:55:44 -0800
commitff0f0aeb401765646fefd9bbdc0f2a68d1ad342c (patch)
tree29e8ca50deb51e8b05072a10e5c60b5e80f65db1 /test/fixtures
parenta0119af0e477d12b69c730336916b49fe0a46aba (diff)
downloadnode-new-ff0f0aeb401765646fefd9bbdc0f2a68d1ad342c.tar.gz
Fix #2507 Raise errors less agressively when destroying stdio streams
Also, if an error is already provided, then raise the provided error, rather than throwing it with a less helpful 'stdout cannot be closed' message. This is important for properly handling EPIPEs.
Diffstat (limited to 'test/fixtures')
-rw-r--r--test/fixtures/catch-stdout-error.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/fixtures/catch-stdout-error.js b/test/fixtures/catch-stdout-error.js
new file mode 100644
index 0000000000..6f96ae9e35
--- /dev/null
+++ b/test/fixtures/catch-stdout-error.js
@@ -0,0 +1,38 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+function write() {
+ try {
+ process.stdout.write('Hello, world\n');
+ } catch (ex) {
+ throw new Error('this should never happen');
+ }
+ process.nextTick(function () {
+ write();
+ });
+}
+
+process.stdout.on('error', function (er) {
+ console.error(JSON.stringify(er));
+ process.exit(42);
+});
+
+write();