Node.jsInterview preparation
Intermediate·Concept·2 min read

What are the main event-loop phases?

Practice this question

Definition:

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.

Key points:

  • 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.

Interview point:

  • Do not promise a universal ordering between top-level setTimeout(0) and setImmediate; their context matters.
Adapted from 02_NODE_EXPRESS_HTTP.md · “What are the main event-loop phases?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.