mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +01:00
2c9e12e496
PR-URL: https://github.com/nodejs/node/pull/25480 Reviewed-By: James M Snell <jasnell@gmail.com>
20 lines
537 B
JavaScript
20 lines
537 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Verify that `.terminate()` interrupts the microtask queue.
|
|
|
|
const worker = new Worker(`
|
|
function loop() { Promise.resolve().then(loop); } loop();
|
|
require('worker_threads').parentPort.postMessage('up');
|
|
`, { eval: true });
|
|
|
|
worker.once('message', common.mustCall(() => {
|
|
setImmediate(() => worker.terminate());
|
|
}));
|
|
|
|
worker.once('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 1);
|
|
}));
|