Replies: 6 comments 17 replies
-
|
Hi @vagostep, Just saw your visualizer - it's really impressive work! This is exactly what developers need to build intuition about Node.js internals. However, the content I'm writing is targeting Node.js v22/v24, and I noticed a few areas where the visualizer could be updated to match the current behavior. The main one that stood out: the execution order between If you're open to it, here are the absolute minimum updates that would make this perfect for learners using current Node.js versions:
The book covers the event loop in extensive detail in Chapters 1.4, 23.1, and 23.2. Your visualizer would be an incredible complement to that content - giving readers a way to actually see what we're describing in text. Would these updates be feasible? I'd love to reference your visualizer in the book as it's such a valuable learning tool. Happy to provide more specific examples of the edge cases if that would help! Thanks for creating this resource for the community! |
Beta Was this translation helpful? Give feedback.
-
|
Hi! @ishtms I added Screen.Recording.2025-09-06.at.11.14.06.PM.movOne thing I found super interesting was, everywhere is talking about how the micro task loop is executed after each Event Loop Phase; and that is not right! The micro task loop (I called Ticks & Rejections Loop in the visualizer) is executed ONLY when an operation is complete. And in Node.js' World, an operation is when passing from C++ code to Javascript code. Quote:
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks again, @vagostep.
That's partly true. The microtask queue is executed after a macrotask finishes, and (this is important) the call stack must be empty. The event loop can't proceed if the call stack isn't empty. So, saying, "It will proceed after any operation" isn't entirely correct.
I was playing with the visualizer and found a couple of issues. The first is an error, The second is a priority issue. The event loop often jumps from the poll phase back to the pending callbacks phase, which isn't supposed to happen. I really appreciate you taking the time to add these features for NodeBook. Once the event loop priority issue is fixed, I'd love to add this to the latest chapter of Event loops on NodeBook. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @ishtms I've added support for CommonJs and ESModules, and a toggle to switch between them. You were right! the Event Loop behaves differently. For ESModules it executes the Event Loop first and when it gets the Poll Phase, it starts to execute the Javascript code Please take a look at the latest version I deployed |
Beta Was this translation helpful? Give feedback.
-
|
Hi @vagostep, I've found that there's some issue when I try to use an import statement while having the "es modules" checkbox active. You might want to look into it? Here's the code I used. import fs from 'fs'
console.log('start');
let i = 1;
const interval = setInterval(function a() {
console.log('Interval ', i++);
if (i > 4) {
clearInterval(interval);
}
}, 100);
console.log('end'); |
Beta Was this translation helpful? Give feedback.
-
|
Hi @ishtms I've added support for dynamically enqueue microTask during MicroTask phase |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all! I've been working on an open source tool, that allows us to visualize how the NodeJs Event Loop works.
I am willing to make this tool useful for everyone who wants to learn more about this topic. This tool is an interactive tool where you can run any code and see how the event loop and nodes handle it!
I'd be awesome if you all consider this tool in the chapters that will cover the Event Loop in this book.
Check it out: https://vagostep.github.io/Node-EventLoop-Visualizer/
I'm maintaining this tool so if you consider more examples, I can add them and if for some reason does not work, I'll fix it.
Beta Was this translation helpful? Give feedback.
All reactions