Async Patterns & Control Flow
6 topics in this chapter
Error-First Callbacks
How Node.js error-first callbacks work, why the first argument carries errors, and how callback dispatch connects native async work back to JavaScript.
Promise Microtasks
How Node.js orders Promise jobs, process.nextTick callbacks, queueMicrotask work, timers, and I/O across CommonJS, ES modules, and active microtask drains.
Async/Await
How async functions and await work in Node.js through promise wrapping, suspension, resumption, microtasks, errors, and V8 state machines.
EventEmitter Internals
How EventEmitter stores listeners, dispatches emit synchronously, handles error events, preserves listener order, and reports possible leaks.
Async Iterators
How async iterators work in Node.js through Symbol.asyncIterator, for await...of, async generators, stream consumption, and backpressure.
Promise Combinators
How Promise.all, allSettled, race, and any behave in Node.js, including short-circuiting, failure propagation, cancellation gaps, and concurrency limits.