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 4c27cf0

Browse filesBrowse files
seanhealyMylesBorins
authored andcommitted
test: refactor callback functions to arrow functions
Refactor callback functions to modern arrow functions. Also, added `common.mustCall` to `online` callbacks. PR-URL: #23546 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1e8ce06 commit 4c27cf0
Copy full SHA for 4c27cf0

File tree

Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-cluster-worker-forced-exit.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-worker-forced-exit.js
+10-12Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ const SENTINEL = 42;
3737
// 3 disconnect worker with child_process's disconnect, confirm
3838
// no sentinel value
3939
if (cluster.isWorker) {
40-
process.on('disconnect', function(msg) {
41-
setTimeout(function() {
42-
process.exit(SENTINEL);
43-
}, 10);
40+
process.on('disconnect', (msg) => {
41+
setTimeout(() => process.exit(SENTINEL), 10);
4442
});
4543
return;
4644
}
@@ -49,17 +47,17 @@ checkUnforced();
4947
checkForced();
5048

5149
function checkUnforced() {
52-
cluster.fork()
53-
.on('online', function() { this.disconnect(); })
54-
.on('exit', common.mustCall(function(status) {
50+
const worker = cluster.fork();
51+
worker
52+
.on('online', common.mustCall(() => worker.disconnect()))
53+
.on('exit', common.mustCall((status) => {
5554
assert.strictEqual(status, SENTINEL);
5655
}));
5756
}
5857

5958
function checkForced() {
60-
cluster.fork()
61-
.on('online', function() { this.process.disconnect(); })
62-
.on('exit', common.mustCall(function(status) {
63-
assert.strictEqual(status, 0);
64-
}));
59+
const worker = cluster.fork();
60+
worker
61+
.on('online', common.mustCall(() => worker.process.disconnect()))
62+
.on('exit', common.mustCall((status) => assert.strictEqual(status, 0)));
6563
}

0 commit comments

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