Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timers: run nextTicks + MTQ between timers / immediates #22316

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,12 @@ function processTimers(now) {
debug('process timer lists %d', now);
nextExpiry = Infinity;

let list, ran;
let list;
while (list = queue.peek()) {
if (list.expiry > now) {
nextExpiry = list.expiry;
return refCount > 0 ? nextExpiry : -nextExpiry;
}
if (ran)
runNextTicks();
else
ran = true;
listOnTimeout(list, now);
}
return 0;
Expand Down Expand Up @@ -300,6 +296,8 @@ function listOnTimeout(list, now) {
tryOnTimeout(timer);

emitAfter(asyncId);

runNextTicks();
}

// If `L.peek(list)` returned nothing, the list was either empty or we have
Expand Down Expand Up @@ -615,6 +613,8 @@ function processImmediate() {

emitAfter(asyncId);

runNextTicks();

immediate = immediate._idleNext;
}

Expand Down