summaryrefslogtreecommitdiff
path: root/test/parallel/test-domain-top-level-error-handler-throw.js
diff options
context:
space:
mode:
authorJeremy Whitlock <jwhitlock@apache.org>2015-10-05 13:08:53 -0700
committerJulien Gilli <julien.gilli@joyent.com>2015-10-05 18:12:43 -0700
commit77a10ed05f1e413818d29f07cbb268108b1f08fa (patch)
tree525e3e0d9c31b94baf34f9e689e95f657df00bf9 /test/parallel/test-domain-top-level-error-handler-throw.js
parent49dec1afd8c310d6995a62893d59b171e2f021cc (diff)
downloadandroid-node-v8-77a10ed05f1e413818d29f07cbb268108b1f08fa.tar.gz
android-node-v8-77a10ed05f1e413818d29f07cbb268108b1f08fa.tar.bz2
android-node-v8-77a10ed05f1e413818d29f07cbb268108b1f08fa.zip
src: fix --abort-on-uncaught-exception
Revert 0af4c9ea7434e4f505dbe071357e4bc3b4ab2a8a, parts of 921f2de6cf999b5a4663615e37967b4269d755fe and port https://github.com/nodejs/node-v0.x-archive/pull/25835 from v0.12 to master so that node aborts at the right time when an error is thrown and --abort-on-uncaught-exception is used. Fixes #3035. PR: #3036 PR-URL: https://github.com/nodejs/node/pull/3036 Reviewed-By: Ben Noordhuis <ben@strongloop.com>
Diffstat (limited to 'test/parallel/test-domain-top-level-error-handler-throw.js')
-rw-r--r--test/parallel/test-domain-top-level-error-handler-throw.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/parallel/test-domain-top-level-error-handler-throw.js b/test/parallel/test-domain-top-level-error-handler-throw.js
new file mode 100644
index 0000000000..2b9e704e43
--- /dev/null
+++ b/test/parallel/test-domain-top-level-error-handler-throw.js
@@ -0,0 +1,50 @@
+'use strict';
+
+/*
+ * The goal of this test is to make sure that when a top-level error
+ * handler throws an error following the handling of a previous error,
+ * the process reports the error message from the error thrown in the
+ * top-level error handler, not the one from the previous error.
+ */
+
+const common = require('../common');
+
+const domainErrHandlerExMessage = 'exception from domain error handler';
+const internalExMessage = 'You should NOT see me';
+
+if (process.argv[2] === 'child') {
+ var domain = require('domain');
+ var d = domain.create();
+
+ d.on('error', function() {
+ throw new Error(domainErrHandlerExMessage);
+ });
+
+ d.run(function doStuff() {
+ process.nextTick(function() {
+ throw new Error(internalExMessage);
+ });
+ });
+} else {
+ var fork = require('child_process').fork;
+ var assert = require('assert');
+
+ var child = fork(process.argv[1], ['child'], {silent:true});
+ var stderrOutput = '';
+ if (child) {
+ child.stderr.on('data', function onStderrData(data) {
+ stderrOutput += data.toString();
+ });
+
+ child.on('exit', function onChildExited(exitCode, signal) {
+ assert(stderrOutput.indexOf(domainErrHandlerExMessage) !== -1);
+ assert(stderrOutput.indexOf(internalExMessage) === -1);
+
+ var expectedExitCode = 7;
+ var expectedSignal = null;
+
+ assert.equal(exitCode, expectedExitCode);
+ assert.equal(signal, expectedSignal);
+ });
+ }
+}