Event loop

RequiredRequired

Juan Camilo ZúñigaBackend & data developer

The event loop takes finished work (a timer that fired, a socket with data, a file that was read) and runs its callback on the main thread, one at a time. While a callback runs, nothing else does.

The rule that follows

Never block the main thread: long CPU work, readFileSync on a request path or a huge JSON.parse stalls every other request. Move that work to a worker thread or split it into smaller pieces.