event-loopAnswer last reviewed July 2026

Here's a scenario. Your Node API's p99 latency blows up on every single endpoint at the same time, but host CPU is sitting at 40 percent. What's your first hypothesis, and how do you confirm it?

Reads every endpoint slowing down at once as a blocked loop, and goes straight to loop-delay instrumentation to confirm it instead of guessing

What an AI-prepared candidate might say

That sounds like blocking the event loop, which is when some synchronous code runs long enough to delay everything else, since Node runs JavaScript on a single thread. The usual causes are the synchronous file system APIs like readFileSync, or heavy computation inside a request handler, or parsing a really large JSON payload. While that code runs, no other callback can execute. So incoming requests just wait, timers fire late, and every endpoint slows down at once, which matches what you described. The standard advice is keep handlers small, use the async versions of those APIs, and move heavy computation out of the request path. To confirm it I'd look through the code for long-running synchronous operations and check whether the latency lines up with a specific type of request. APM tracing or a profiler can help narrow down which route it is.

Senior
Locked

Everything that blocks a loop besides fs.readFileSync, from JSON.parse size thresholds to regex backtracking to hot loops, and the three symptoms that tell a blocked loop apart from slow downstreams.

Unlock the depth
Staff
Locked

How to actually catch the offending stack in production, with a profiler you can run on a degraded pod, and the guardrails that stop this whole class of bug from coming back.

Unlock the depth
Follow-up chain
Here's a scenario. Your Node API's p99 latency blows up on every single endpoint at the same time, but host CPU is sitting at 40 percent. What's your first hypothesis, and how do you confirm it? | NodeBook