Detecting Event Loop Blocking in Production Node.js — Without Touching Your Code

TL;DR AI
2 min readKey summary
Node-loop-detective attaches to a running Node.js process and detects event loop blocking, identifying the exact function and file.
Node.js runs JavaScript on a single thread; the event loop is the scheduler for callbacks.
Event loop blocking occurs when a callback takes too long, causing other work to wait.
Common causes include JSON.parse on a 50MB payload; regex catastrophic backtracking; readFileSync left in a request handler; tight CPU-intensive loops; and excessive garbage collection from rapid allocations.
Production with high request rates can reveal issues not seen in staging; many existing tools require restarting or redeploying, while SIGUSR1 activates the V8 Inspector (port 9229) which accepts CDP connections.
