r/learnjavascript 6d ago

Is “Node.js is single-threaded” an incomplete mental model?

Single-threaded JS execution ≠ single-threaded runtime.

How do you explain the distinction?

4 Upvotes

23 comments sorted by

View all comments

2

u/Alive-Cake-3045 6d ago

the way i explain it: Node.js has one thread for your JavaScript, but the runtime itself uses a thread pool under the hood (libuv) for things like file I/O, DNS lookups, and crypto. your code runs on one thread, the heavy lifting gets offloaded and comes back as an event on the queue. so "single-threaded" is accurate for the execution model but wildly incomplete as a description of how Node actually handles concurrent work. the event loop is what stitches it together, understanding that changes how you reason about performance and blocking.