Guia de entrevista · Node.js

The Event Loop

do caderno de estudos · atualizado em 2 de outubro de 2026
Para quem vai encarar entrevista de Node.js2 min

Não decore palavra por palavra: entenda a estrutura da resposta e refaça com as suas palavras, em inglês.

A resposta, como você fala na entrevista
  1. JavaScript runs one callback at a time on each Node.js event-loop thread.
  2. Non-blocking I/O uses the OS or LibUV's worker pool. CPU-heavy JavaScript still blocks that thread.
  3. Ready callbacks run in event-loop phases, including timers, pending callbacks, poll (I/O), check (setImmediate), and close callbacks.
  4. Promise reactions and queueMicrotask callbacks use V8's microtask queue, which drains at microtask checkpoints before normal event-loop work resumes.
  5. Node also has a separate process.nextTick queue. Its ordering relative to microtasks depends on the execution context (see below).

There is NO single FIFO queue across timers, I/O, and setImmediate: their order depends on phases and readiness. FIFO applies within phase queues, not globally. Microtasks added while the microtask queue drains also run before it finishes, so an endless chain can starve the loop.

Timers, setImmediate, and I/O callbacks are often called macrotasks, but that shorthand must not hide Node's distinct phases. LibUV drives the event loop. V8 manages the Promise/queueMicrotask queue.

Ler é o primeiro passo. No app, essa pergunta vira flashcard com repetição espaçada, e o módulo tem quiz e simulado para testar o que ficou.

Treinar essa pergunta no app