Skip to content

Commit c8b5df2

Browse files
committed
run microtasks before ticks
This resolve multiple timing issues related to promises and nextTick. As well as resolving zaldo in promise only code, i.e. our current best practice of using process.nextTick will always apply and work. Refs: #51156 Refs: #51156 (comment) Refs: #51114 (comment) Refs: #51070 Refs: #51156
1 parent fc102f2 commit c8b5df2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/process/task_queues.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function runNextTicks() {
6767
function processTicksAndRejections() {
6868
let tock;
6969
do {
70+
runMicrotasks();
7071
while ((tock = queue.shift()) !== null) {
7172
const asyncId = tock[async_id_symbol];
7273
emitBefore(asyncId, tock[trigger_async_id_symbol], tock);
@@ -92,7 +93,6 @@ function processTicksAndRejections() {
9293

9394
emitAfter(asyncId);
9495
}
95-
runMicrotasks();
9696
} while (!queue.isEmpty() || processPromiseRejections());
9797
setHasTickScheduled(false);
9898
setHasRejectionToWarn(false);

0 commit comments

Comments
 (0)