Q14: What causes Event Loop starvation and how do you fix it?

Event loop starvation happens when long-running synchronous code or continuous microtasks prevent the Event Loop from advancing to pending I/O phases. Break up work using setImmediate().

Key Takeaways
  • Heavy sync loops hold main thread control continuously.
  • Offload calculations to Worker Threads or partition iterations using setImmediate().
Knowledge Check

How can you partition long synchronous array processing to yield to I/O?