Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to theΒ pollΒ queue to eventually be executed.
Each phase has itβs own FIFO queue of callbacks to execute
On entering each phase, it will perform any operations specific to that phase, then execute callbacks in that phaseβs queue until the queue has been exhausted or the maximum number of callbacks has executed
Phases
Timers: execute any setTimeout() and setInterval() callbacks given that enough time has passed since they were scheduled
Pending callbacks: certain types of I/O callbacks (i.e. TCPECONNREFUSED)
Idle, prepare: Node internals
Poll: wait for system to call us back for I/O events (normally, this is where Node chooses to block)