1'use strict'; 2const common = require('../common'); 3const { Worker } = require('worker_threads'); 4 5// Checks that terminating in the middle of `process.nextTick()` does not 6// Crash the process. 7 8const w = new Worker(` 9require('worker_threads').parentPort.postMessage('0'); 10process.nextTick(() => { 11 while(1); 12}); 13`, { eval: true }); 14 15// Test deprecation of .terminate() with callback. 16common.expectWarning( 17 'DeprecationWarning', 18 'Passing a callback to worker.terminate() is deprecated. ' + 19 'It returns a Promise instead.', 'DEP0132'); 20 21w.on('message', common.mustCall(() => { 22 setTimeout(() => { 23 w.terminate(common.mustCall()).then(common.mustCall()); 24 }, 1); 25})); 26