Skip to content

Commit

Permalink
test: work scheduled in process.nextTick can keep the event loop alive
Browse files Browse the repository at this point in the history
PR-URL: #43787
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
  • Loading branch information
andreubotella authored and targos committed Jul 31, 2022
1 parent 319ca2d commit f03c774
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/parallel/test-process-beforeexit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@ function tryRepeatedTimer() {
if (++n < N)
setTimeout(repeatedTimer, 1);
else // n == N
process.once('beforeExit', common.mustCall(tryNextTick));
process.once('beforeExit', common.mustCall(tryNextTickSetImmediate));
}, N);
setTimeout(repeatedTimer, 1);
}

// Test if the callback of `process.nextTick` can be invoked.
function tryNextTickSetImmediate() {
process.nextTick(common.mustCall(function() {
setImmediate(common.mustCall(() => {
process.once('beforeExit', common.mustCall(tryNextTick));
}));
}));
}

// Test that `process.nextTick` won't keep the event loop running by itself.
function tryNextTick() {
process.nextTick(common.mustCall(function() {
process.once('beforeExit', common.mustNotCall());
Expand Down

0 comments on commit f03c774

Please sign in to comment.