mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

This adds a regression test for terminating a Worker inside which another Worker is running. PR-URL: https://github.com/nodejs/node/pull/32623 Refs: https://github.com/nodejs/node/pull/32531 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
16 lines
478 B
JavaScript
16 lines
478 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Check that a Worker that's running another Worker can be terminated.
|
|
|
|
const worker = new Worker(`
|
|
const { Worker, parentPort } = require('worker_threads');
|
|
const worker = new Worker('setInterval(() => {}, 10);', { eval: true });
|
|
worker.on('online', () => {
|
|
parentPort.postMessage({});
|
|
});
|
|
`, { eval: true });
|
|
|
|
worker.on('message', common.mustCall(() => worker.terminate()));
|