QuizNot attempted
Starving the event loop
1–4 to choose, Enter to submit
Show answer & explanation
Correct answers:
JSON.parseon a 50MB string, or a CPU-heavy loop in a request handler or Server Component- A recursive process.nextTick chain that never ends
- Node runs your JS on one thread, so synchronous CPU work (
JSON.parseof 50MB, a heavy loop) blocks every request, and a never-endingprocess.nextTickchain starves the loop because the nextTick queue is drained before any phase can run. - Not awaiting a slow query: the await yields, and the loop serves others meanwhile.
- Not many requests waiting on the network: waiting on I/O is non-blocking.
- Offload CPU work to
worker_threads, a queue, or another service.