The Runtime Theory
Event Loops and Async Execution

Async Code Still Runs on an Event Loop

An event loop repeatedly selects ready work and runs callbacks or tasks.

The Runtime Theory Team5 min read#event-loop#async#nonblocking
▸ On this page

The model

An event loop repeatedly selects ready work and runs callbacks or tasks. Asynchronous I/O lets a program arrange for completion to be reported later so the thread can do other work meanwhile. The syntax may look sequential, but the runtime schedules continuations according to its queues and rules.

A concrete walk-through

When a Node.js handler starts a network request, the runtime registers work with the operating system or an internal pool. The JavaScript callback runs after completion is reported and scheduled. A long synchronous calculation inside one callback still occupies the event-loop thread and delays unrelated requests.

Costs and failure cases

Async does not mean parallel, and adding await does not make CPU-heavy work nonblocking. Queue ordering differs across runtimes and task classes. Unhandled rejections, cancellation, and timeouts need explicit policies so stalled work does not linger indefinitely.

Check your understanding

A service has fast network I/O but slow response times whenever it generates a large report. Explain how an event-loop blocker creates that symptom and how you would move or divide the computation.

Further reading

Node.js: Don’t Block the Event Loop

Not started

Sign in to save your learning progress.

Sign in to save