diff --git a/lib/timers.js b/lib/timers.js index dc9b875ec374c9..6e473456b9affe 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -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; @@ -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 @@ -615,6 +613,8 @@ function processImmediate() { emitAfter(asyncId); + runNextTicks(); + immediate = immediate._idleNext; }