node js – what happens to incoming events during callback excution

They are added to queue and processed later:

A JavaScript runtime contains a message queue, which is a list of messages to be processed. A function is associated with each message. When the stack is empty, a message is taken out of the queue and processed. The processing consists of calling the associated function (and thus creating an initial stack frame). The message processing ends when the stack becomes empty again.

Concurrency model and Event Loop

Leave a Comment