mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

This makes sure `process._fatalException()` returns a boolean when run inside of a worker. PR-URL: https://github.com/nodejs/node/pull/29706 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
26 lines
676 B
JavaScript
26 lines
676 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Check that `process._fatalException()` returns a boolean when run inside a
|
|
// worker.
|
|
|
|
// 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, 0);
|
|
}));
|
|
return;
|
|
}
|
|
|
|
process.once('uncaughtException', () => {
|
|
process.nextTick(() => {
|
|
assert.strictEqual(res, true);
|
|
});
|
|
});
|
|
|
|
const res = process._fatalException(new Error());
|