The NodeJS event loop

1 min read

What is the NodeJS event loop? In this article I'm trying to explain a core piece of NodeJS in an easy way.

So NodeJS is a single threaded language by design. But then how does the UI thread not get blocked by requests and so on? You’d say async and Promises. And you’ll be right. But how that does work under the hood? What happens when you call setTimeout, when you call fetch, and so on?

The attempt of this article is to clarify exactly that.

TLDR: There is indeed a single thread handling all the calls you make, but the key here is the architecture of NodeJS. There’s the event loop which is the central piece. Think of it as the handler. The response of each function that you call is resolved at the different stages (phases) of the event loop.

Tags

Related Posts

No related posts yet.