How Node.js Runs Your Code

Event loop · Thread pool · Workers · Isolation

Main thread - one V8 isolate, one event loop your JavaScript runs here
1 pending
2 idle/prep
3 poll · I/O
4 check
5 close
6 timers
one iteration, then back to pending. Since libuv 1.45 (Node 20) timers run at the end of an iteration
Call stackLIFO · 1 at a time
Between-callback queuesdrained before the loop advances
process.nextTick queue (Node) · drains first
microtask queue (V8: Promise, await) · second
libuv thread pool×4 · process‑global
thread 1
thread 2
thread 3
thread 4
Kernel async I/Oepoll · kqueue · IOCP
Worker threadsown isolate + loop
Worker #1 · separate V8 isolate

Three unrelated sets of threads: V8's own GC/JIT helpers, libuv's process‑global pool of 4, and any worker threads you spawn. Only worker threads run your JavaScript.