There is no single “4-thread pool” doing everything. Each subsystem owns its threads:
JavaScript itself never runs in parallel with other JavaScript. Two JS
sections execute one after the other, always.
Decision table
Example: parallel fan-out
fetch slot has its own
thread, so a fan-out like this costs one loop, not three.
Top-levelawaitworks in files (modules). It does not work inff -e '...', which is evaluated as a script — wrap it in an async IIFE there, or put the code in a file.
Example: non-blocking file I/O in a handler
Example: CPU-bound work → Worker
console, timers, structuredClone, crypto (randomUUID, getRandomValues, subtle, btoa, atob; no crypto.bcrypt), postMessage, workerData, and
performance — no fs, no fetch, no http.serve, no crypto.bcrypt.
Limits worth memorising
Gotchas
Promise.allfails fast — one rejection rejects the whole batch. UsePromise.allSettledwhen every result matters.- Sync
fs, a longwhileloop, or a big synchronous parse delays every pending timer and connection. - Workers never exit on their own; the process waits for
terminate(). - Worker files are classic scripts —
import/exportinside a worker throws.
See also
- Event loop
- Workers · API: Worker
- API: fs — sync vs
*Async - Limitations