event loop starvation
When the event loop can never move on because code keeps scheduling more immediate work, so timers and I/O are never handled.
In more detail
Recursive process.nextTick() calls, or promises that keep queuing more promises, cause it because those queues are always emptied first. Using setImmediate() for recurring work lets the loop complete a full turn between steps.
Related terms
- process.nextTick() — A Node.js function that queues a callback to run as soon as the current operation finishes, before promise callbacks and before the event loop continues.
- microtask — A small job, such as a promise callback, that runs as soon as the current piece of JavaScript finishes, before the event loop handles anything else.
- setImmediate() — A Node.js function that runs a callback in the check phase of the current event loop turn, right after I/O has been processed.
Taught in
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services
- Microtask Queues: process.nextTick vs Promise Timing — Node.js Internals & Backend Services
- Poll & Check Phases: I/O Callbacks & setImmediate — Node.js Internals & Backend Services