Skip to content
Permalink
Browse files
test: work scheduled in process.nextTick can keep the event loop alive
PR-URL: #43787
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
  • Loading branch information
andreubotella authored and danielleadams committed Jul 26, 2022
1 parent cd0d9dd commit 88505556feba69ce2a2da9e3e7cc3a4008221c37
Showing 1 changed file with 10 additions and 1 deletion.
@@ -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());

0 comments on commit 8850555

Please sign in to comment.