GeezerVison is showing github.com — src: honor --abort_on_uncaught_exception flag · nodejs/node@2034f68
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node.cc +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2192,7 +2192,11 @@ void FatalException(Isolate* isolate, |
2192 | 2192 |
|
2193 | 2193 | if (false == caught->BooleanValue()) { |
2194 | 2194 | ReportException(env, error, message); |
2195 | | - exit(1); |
| 2195 | + if (abort_on_uncaught_exception) { |
| 2196 | + ABORT(); |
| 2197 | + } else { |
| 2198 | + exit(1); |
| 2199 | + } |
2196 | 2200 | } |
2197 | 2201 | } |
2198 | 2202 |
|
|
Collapse file
Copy file name to clipboard +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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 | +} |