Skip to catalogue

261

event loop

also microtask, macrotask, Node event loop

One thread runs your JavaScript. A long synchronous call blocks every request on it.

What is event loop?

The event loop runs the call stack, then microtasks such as promise reactions, then one macrotask such as a timer or I/O callback. Node shares that loop across requests on the thread. fs.readFileSync, a huge JSON.parse, or synchronous crypto stops every other request. Promises are not parallelism.

Why does event loop matter when vibe coding?

The draft hashes a password with a sync call, or reads a file with readFileSync, inside the handler. Under one user it is fine. Under ten, the process stops answering health checks.

How do you do event loop?

Keep the handler async and short. Move CPU work to a worker or a queue. Do not use the sync filesystem or sync crypto on the request path.

How do you ask a model for event loop?

Handle (request) on the event loop without blocking. Use async I/O. Do not call readFileSync, bcrypt sync, or a long JSON parse in the handler. Move CPU work to a worker.

What goes wrong with event loop?

A microtask loop that never returns to the macrotask queue. Timers and I/O starve while promises schedule more promises.

adjacent