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

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

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

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