mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
8438f3b73b
Cope with the delay(to the next function call) of v8::Isolate::TerminateExecution() PR-URL: https://github.com/nodejs/node/pull/45620 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
24 lines
589 B
JavaScript
24 lines
589 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
if (isMainThread) {
|
|
const workerData = new Int32Array(new SharedArrayBuffer(4));
|
|
new Worker(__filename, {
|
|
workerData,
|
|
});
|
|
process.on('beforeExit', common.mustCall(() => {
|
|
assert.strictEqual(workerData[0], 0);
|
|
}));
|
|
} else {
|
|
const { workerData } = require('worker_threads');
|
|
try {
|
|
process.exit();
|
|
throw new Error('xxx');
|
|
// eslint-disable-next-line no-unused-vars
|
|
} catch (err) {
|
|
workerData[0] = 1;
|
|
}
|
|
}
|