Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add Worker + uncaughtException + process.exit() test
  • Loading branch information
addaleax committed Jun 17, 2019
commit 6401e56b3aca856bde42f59ca4fcd20ebc03b1b9
21 changes: 21 additions & 0 deletions test/parallel/test-worker-exit-from-uncaught-exception.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { isMainThread, Worker } = require('worker_threads');

// Check that `process.exit()` can be called inside a Worker from an uncaught
// exception handler.

if (isMainThread) {
const w = new Worker(__filename);
w.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 42);
}));
return;
}

process.on('uncaughtException', () => {
process.exit(42);
});

throw new Error();