mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
85b95cc6a3
When running Worker threads with `--abort-on-uncaught-exception`, do not abort the process when `worker.terminate()` is called. PR-URL: https://github.com/nodejs/node/pull/26111 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
25 lines
690 B
JavaScript
25 lines
690 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawn } = require('child_process');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Tests that --abort-on-uncaught-exception applies to workers as well.
|
|
|
|
if (process.argv[2] === 'child') {
|
|
new Worker('throw new Error("foo");', { eval: true });
|
|
return;
|
|
}
|
|
|
|
const child = spawn(process.execPath, [
|
|
'--abort-on-uncaught-exception', __filename, 'child'
|
|
]);
|
|
child.on('exit', common.mustCall((code, sig) => {
|
|
if (common.isWindows) {
|
|
assert.strictEqual(code, 0xC0000005);
|
|
} else {
|
|
assert(['SIGABRT', 'SIGTRAP', 'SIGILL'].includes(sig),
|
|
`Unexpected signal ${sig}`);
|
|
}
|
|
}));
|