mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
48b159562d
To be more precise, fix a crash when `worker.unref()` is called from a message on the Worker that is not emitted before the Worker thread has stopped. PR-URL: https://github.com/nodejs/node/pull/33394 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
17 lines
492 B
JavaScript
17 lines
492 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// This used to crash because the `.unref()` was unexpected while the Worker
|
|
// was exiting.
|
|
|
|
const w = new Worker(`
|
|
require('worker_threads').parentPort.postMessage({});
|
|
`, { eval: true });
|
|
w.on('message', common.mustCall(() => {
|
|
w.unref();
|
|
}));
|
|
|
|
// Wait a bit so that the 'message' event is emitted while the Worker exits.
|
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|