node/test/parallel/test-worker-terminate-ref-p...

13 lines
415 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'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());