Facebook Pixel

Can microtasks block macrotasks in JavaScript?

Yes. If a microtask keeps adding more microtasks, the event loop never reaches the macrotask queue or rendering, freezing the page. Always keep microtask chains bounded.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Call Stack vs Task Queue in JavaScript

The call stack runs synchronous code immediately, one frame at a time. The task queue (macrotask queue) holds callbacks from setTimeout and events, waiting to run when the stack is empty.

The Promise callback. Promise.then callbacks go to the microtask queue, which the event loop drains completely before touching the macrotask queue where setTimeout callbacks live.

Microtasks (Promise.then, queueMicrotask) are drained completely before each macrotask and before rendering. Macrotasks (setTimeout, events) run one at a time, with microtasks drained after each.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.