Node.js · Middle · Question 6 of 75
A request handler runs a CPU-heavy loop for 2 seconds. What happens to other requests?
- 1They are processed in parallel on other threads automatically
- ✓Correct answer: They wait: while JavaScript runs on the main thread, the event loop can't handle anything else
- 3Node.js stops the loop after 100 ms
Explanation
Move heavy CPU work to worker_threads, a separate service or a job queue, or split it into small chunks with setImmediate between them.