1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const { spawn } = require('child_process'); 5const { Worker } = require('worker_threads'); 6 7// Tests that --abort-on-uncaught-exception applies to workers as well. 8 9if (process.argv[2] === 'child') { 10 new Worker('throw new Error("foo");', { eval: true }); 11 return; 12} 13 14const child = spawn(process.execPath, [ 15 '--abort-on-uncaught-exception', __filename, 'child', 16]); 17child.on('exit', common.mustCall((code, sig) => { 18 if (common.isWindows) { 19 assert.strictEqual(code, 0xC0000005); 20 } else { 21 assert(['SIGABRT', 'SIGTRAP', 'SIGILL'].includes(sig), 22 `Unexpected signal ${sig}`); 23 } 24})); 25