0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/abort/test-worker-abort-uncaught-exception.js
Anna Henningsen 85b95cc6a3
worker: ignore --abort-on-uncaught-exception for terminate()
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>
2019-02-18 09:17:11 +01:00

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}`);
}
}));