summaryrefslogtreecommitdiff
path: root/test/abort/test-worker-abort-uncaught-exception.js
blob: 63f7acdddc7fd7b51e4a7b278fdeea2dc83a916a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const common = require('../common');
const assert = require('assert');
const { spawn } = require('child_process');
const { Worker } = require('worker_threads');

// Tests that --abort-on-uncaught-exception applies to workers as well.

if (process.argv[2] === 'child') {
  new Worker('throw new Error("foo");', { eval: true });
  return;
}

const child = spawn(process.execPath, [
  '--abort-on-uncaught-exception', __filename, 'child'
]);
child.on('exit', common.mustCall((code, sig) => {
  if (common.isWindows) {
    assert.strictEqual(code, 0xC0000005);
  } else {
    assert(['SIGABRT', 'SIGTRAP', 'SIGILL'].includes(sig),
           `Unexpected signal ${sig}`);
  }
}));