mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

PR-URL: https://github.com/nodejs/node/pull/28259 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
24 lines
607 B
JavaScript
24 lines
607 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Check that `process.exit()` can be called inside a Worker from an uncaught
|
|
// exception handler.
|
|
|
|
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
|
if (!process.env.HAS_STARTED_WORKER) {
|
|
process.env.HAS_STARTED_WORKER = 1;
|
|
const w = new Worker(__filename);
|
|
w.on('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 42);
|
|
}));
|
|
return;
|
|
}
|
|
|
|
process.on('uncaughtException', () => {
|
|
process.exit(42);
|
|
});
|
|
|
|
throw new Error();
|