LESSON 03 / 22·2 min readIntermediate

What are the main event-loop phases?

Try code in the playground
01 Understand02 Recall03 Prepare

Understand the concept

The event loop is the scheduling mechanism that decides when ready callbacks can run. Node organizes several categories of callbacks into phases, with separate processing for promise microtasks and next-tick callbacks. A timer delay is a minimum waiting threshold, not a promise of an exact execution time.

Important ideas

  • Timers handle eligible timer callbacks; poll handles I/O; check handles setImmediate.
  • Pending callbacks and close callbacks have their own phases too.
  • Promise microtasks and process.nextTick callbacks run at checkpoints, outside this phase list.

Reference: Node event loop.

  • Repeatedly scheduling microtasks or next-tick callbacks can delay I/O even though each callback is short.
PAUSE & RECALL

Can you explain it without the notes?

What are the main event-loop phases?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

The event loop is the scheduling mechanism that decides when ready callbacks can run. Node organizes several categories of callbacks into phases, with separate processing for promise microtasks and next-tick callbacks. A timer delay is a minimum waiting threshold, not a promise of an exact execution time.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Do not promise a universal ordering between top-level setTimeout(0) and setImmediate; their context matters.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Worker thread vs process: when would I use each?

Adapted from 02_NODE_EXPRESS_HTTP.md · “What are the main event-loop phases?”. Examples are study fragments; framework behavior can depend on your version.