Files
Kmake/test/parallel/test-worker-terminate-ref-public-port.js

13 lines
415 B
JavaScript
Raw Permalink Normal View History

2026-05-26 23:36:42 -07:00
'use strict';
const common = require('../common');
const { Worker } = require('worker_threads');
// The actual test here is that the Worker does not keep the main thread
// running after it has been .terminate()ed.
const w = new Worker(`
const p = require('worker_threads').parentPort;
while(true) p.postMessage({})`, { eval: true });
w.once('message', () => w.terminate());
w.once('exit', common.mustCall());