Loading
The engine that keeps Node.js running, checking for new tasks and executing callbacks — like a waiter who loops around tables taking and delivering orders nonstop.
A single-threaded mechanism that handles asynchronous operations by polling for I/O events and executing callbacks in a defined phase order: timers, pending callbacks, poll, check (setImmediate), and close callbacks.
libuv's event loop executes in six phases per iteration: timers (setTimeout/setInterval callbacks whose threshold has elapsed), pending I/O callbacks (deferred from the previous loop), idle/prepare (internal), poll (retrieve new I/O events, execute I/O callbacks, block if empty), check (setImmediate), and close callbacks. process.nextTick and resolved Promises (microtasks) drain between every phase transition, which can starve the event loop if used recursively.