Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 72f52a3

Browse filesBrowse files
addaleaxtargos
authored andcommitted
test: add Worker + uncaughtException + process.exit() test
PR-URL: #28259 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 5b92eb4 commit 72f52a3
Copy full SHA for 72f52a3

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Open diff view settings
Collapse file
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const { Worker } = require('worker_threads');
5+
6+
// Check that `process.exit()` can be called inside a Worker from an uncaught
7+
// exception handler.
8+
9+
// Do not use isMainThread so that this test itself can be run inside a Worker.
10+
if (!process.env.HAS_STARTED_WORKER) {
11+
process.env.HAS_STARTED_WORKER = 1;
12+
const w = new Worker(__filename);
13+
w.on('exit', common.mustCall((code) => {
14+
assert.strictEqual(code, 42);
15+
}));
16+
return;
17+
}
18+
19+
process.on('uncaughtException', () => {
20+
process.exit(42);
21+
});
22+
23+
throw new Error();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.