diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js index bcb5eef841dd00..04bdb071227553 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -67,6 +67,7 @@ function runNextTicks() { function processTicksAndRejections() { let tock; do { + runMicrotasks(); while ((tock = queue.shift()) !== null) { const asyncId = tock[async_id_symbol]; emitBefore(asyncId, tock[trigger_async_id_symbol], tock); @@ -92,7 +93,6 @@ function processTicksAndRejections() { emitAfter(asyncId); } - runMicrotasks(); } while (!queue.isEmpty() || processPromiseRejections()); setHasTickScheduled(false); setHasRejectionToWarn(false);