summaryrefslogtreecommitdiff
path: root/test/parallel/test-domain-abort-on-uncaught.js
diff options
context:
space:
mode:
authorChris Dickinson <christopher.s.dickinson@gmail.com>2015-02-22 14:54:25 -0800
committerChris Dickinson <christopher.s.dickinson@gmail.com>2015-02-25 14:01:29 -0800
commit0af4c9ea7434e4f505dbe071357e4bc3b4ab2a8a (patch)
tree1cf138f18ca90b5262abe9c2c9f3b16482740011 /test/parallel/test-domain-abort-on-uncaught.js
parent2ca22aacbdd11c572e71ee1b15af3bec1e04a0c1 (diff)
downloadandroid-node-v8-0af4c9ea7434e4f505dbe071357e4bc3b4ab2a8a.tar.gz
android-node-v8-0af4c9ea7434e4f505dbe071357e4bc3b4ab2a8a.tar.bz2
android-node-v8-0af4c9ea7434e4f505dbe071357e4bc3b4ab2a8a.zip
src: fix domains + --abort-on-uncaught-exception
If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode. This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode. Semver: patch PR-URL: https://github.com/iojs/io.js/pull/922 Fixes: https://github.com/iojs/io.js/issues/836 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-domain-abort-on-uncaught.js')
-rw-r--r--test/parallel/test-domain-abort-on-uncaught.js109
1 files changed, 109 insertions, 0 deletions
diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js
new file mode 100644
index 0000000000..9a4bd132a3
--- /dev/null
+++ b/test/parallel/test-domain-abort-on-uncaught.js
@@ -0,0 +1,109 @@
+var common = require('../common');
+var assert = require('assert');
+var spawn = require('child_process').spawn;
+
+var tests = [
+ nextTick,
+ timer,
+ timerPlusNextTick,
+ firstRun,
+ netServer
+]
+
+tests.forEach(function(test) {
+ console.log(test.name);
+ var child = spawn(process.execPath, [
+ '--abort-on-uncaught-exception',
+ '-e',
+ '(' + test + ')()',
+ common.PORT
+ ]);
+ child.stderr.pipe(process.stderr);
+ child.stdout.pipe(process.stdout);
+ child.on('exit', function(code) {
+ assert.strictEqual(code, 0);
+ });
+});
+
+function nextTick() {
+ var domain = require('domain');
+ var d = domain.create();
+
+ d.on('error', function(err) {
+ console.log('ok');
+ process.exit(0);
+ });
+ d.run(function() {
+ process.nextTick(function() {
+ throw new Error('exceptional!');
+ });
+ });
+}
+
+function timer() {
+ var domain = require('domain');
+ var d = domain.create();
+
+ d.on('error', function(err) {
+ console.log('ok');
+ process.exit(0);
+ });
+ d.run(function() {
+ setTimeout(function() {
+ throw new Error('exceptional!');
+ }, 33);
+ });
+}
+
+function timerPlusNextTick() {
+ var domain = require('domain');
+ var d = domain.create();
+
+ d.on('error', function(err) {
+ console.log('ok');
+ process.exit(0);
+ });
+ d.run(function() {
+ setTimeout(function() {
+ process.nextTick(function() {
+ throw new Error('exceptional!');
+ });
+ }, 33);
+ });
+}
+
+function firstRun() {
+ var domain = require('domain');
+ var d = domain.create();
+
+ d.on('error', function(err) {
+ console.log('ok');
+ process.exit(0);
+ });
+ d.run(function() {
+ throw new Error('exceptional!');
+ });
+}
+
+function netServer() {
+ var domain = require('domain');
+ var net = require('net');
+ var d = domain.create();
+
+ d.on('error', function(err) {
+ console.log('ok');
+ process.exit(0);
+ });
+ d.run(function() {
+ var server = net.createServer(function(conn) {
+ conn.pipe(conn);
+ });
+ server.listen(Number(process.argv[1]), '0.0.0.0', function() {
+ var conn = net.connect(Number(process.argv[1]), '0.0.0.0')
+ conn.once('data', function() {
+ throw new Error('ok');
+ })
+ conn.end('ok');
+ });
+ });
+}