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

PR-URL: https://github.com/nodejs/node/pull/32541 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
24 lines
721 B
JavaScript
24 lines
721 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Test that calling worker.terminate() if kHandler is null should return an
|
|
// empty promise that resolves to undefined, even when a callback is passed
|
|
|
|
const worker = new Worker(`
|
|
const { parentPort } = require('worker_threads');
|
|
parentPort.postMessage({ hello: 'world' });
|
|
`, { eval: true });
|
|
|
|
process.once('beforeExit', common.mustCall(() => worker.ref()));
|
|
|
|
worker.on('exit', common.mustCall(() => {
|
|
worker.terminate().then((res) => assert.strictEqual(res, undefined));
|
|
worker.terminate(() => null).then(
|
|
(res) => assert.strictEqual(res, undefined)
|
|
);
|
|
}));
|
|
|
|
worker.unref();
|