summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-nexttick-terminate.js
blob: 269509178fac6efca23eaefec66a4221bb19a007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const common = require('../common');
const { Worker } = require('worker_threads');

// Checks that terminating in the middle of `process.nextTick()` does not
// Crash the process.

const w = new Worker(`
require('worker_threads').parentPort.postMessage('0');
process.nextTick(() => {
  while(1);
});
`, { eval: true });

w.on('message', common.mustCall(() => {
  setTimeout(() => {
    w.terminate(common.mustCall());
  }, 1);
}));