summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-terminate-nested.js
blob: 3924528cea1ccb6b9ec23c21a1d6e4adf7656193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'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()));