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 db7b27a

Browse filesBrowse files
TrottItalo A. Casas
authored andcommitted
test: refactor beforeExit tests
Combine and rename tests for the `beforeExit` event on `process`. The naming now more closely follows the de facto conventions of the project. The two tests were very similar and do not seem to benefit from being separate. PR-URL: #10581 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 33851d1 commit db7b27a
Copy full SHA for db7b27a

File tree

Expand file treeCollapse file tree

2 files changed

+14
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-15
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-process-before-exit.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-process-before-exit.js
-14Lines changed: 0 additions & 14 deletions
This file was deleted.
Collapse file
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ function tryListen() {
2121
.listen(0)
2222
.on('listening', common.mustCall(function() {
2323
this.close();
24-
process.on('beforeExit', common.mustCall(() => {}));
24+
process.once('beforeExit', common.mustCall(tryRepeatedTimer));
2525
}));
2626
}
27+
28+
// test that a function invoked from the beforeExit handler can use a timer
29+
// to keep the event loop open, which can use another timer to keep the event
30+
// loop open, etc.
31+
function tryRepeatedTimer() {
32+
const N = 5;
33+
let n = 0;
34+
const repeatedTimer = common.mustCall(function() {
35+
if (++n < N)
36+
setTimeout(repeatedTimer, 1);
37+
}, N);
38+
setTimeout(repeatedTimer, 1);
39+
}

0 commit comments

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