Skip to content
This repository was archived by the owner on Oct 16, 2021. It is now read-only.

Commit 921f2de

Browse files
committed
src: honor --abort_on_uncaught_exception flag
Fix regression introduced in 0af4c9e that ignores the --abort-on-uncaught-exception flag. Prior to that commit, the flag was passed through to v8. After that commit, the process just calls exit(1). PR-URL: nodejs/node#2776 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-by: Trevor Norris <[email protected]>
1 parent 870229e commit 921f2de

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/node.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,11 @@ void FatalException(Isolate* isolate,
21802180

21812181
if (false == caught->BooleanValue()) {
21822182
ReportException(env, error, message);
2183-
exit(1);
2183+
if (abort_on_uncaught_exception) {
2184+
ABORT();
2185+
} else {
2186+
exit(1);
2187+
}
21842188
}
21852189
}
21862190

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const spawn = require('child_process').spawn;
6+
const node = process.execPath;
7+
8+
if (process.argv[2] === 'child') {
9+
throw new Error('child error');
10+
} else {
11+
run('', null);
12+
run('--abort-on-uncaught-exception', 'SIGABRT');
13+
}
14+
15+
function run(flags, signal) {
16+
const args = [__filename, 'child'];
17+
if (flags)
18+
args.unshift(flags);
19+
20+
const child = spawn(node, args);
21+
child.on('exit', common.mustCall(function(code, sig) {
22+
if (!common.isWindows) {
23+
assert.strictEqual(sig, signal);
24+
} else {
25+
if (signal)
26+
assert.strictEqual(code, 3);
27+
else
28+
assert.strictEqual(code, 1);
29+
}
30+
}));
31+
}

0 commit comments

Comments
 (0)