Check out my Node.js Learning Path, available from IBM Developer.
The Learning Path consists of 14 units, each designed to take you further into the world of Node.js.
Start your Node.js journey now at IBM Developer.
Thanks for reading!
–jsp
Check out my Node.js Learning Path, available from IBM Developer.
The Learning Path consists of 14 units, each designed to take you further into the world of Node.js.
Start your Node.js journey now at IBM Developer.
Thanks for reading!
–jsp
Hi Steven,
Thank you for this excellent learning path for Node.js. I’m really enjoying it so far. Kudos for examples.
As I’m currently going through the units, I noticed that output of example 5 in “Unit 5: the event loop” (https://developer.ibm.com/tutorials/learn-nodejs-the-event-loop/) is different when I run it locally.
Specially to what I want to bring attention is the poll phase and accompanied microtasks, which were run 4 times in the example output on the IBM site:
...
1530401857787:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1530401857787:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1530401857787:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1530401857787:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
...
1530401857788:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1530401857788:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1530401857788:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1530401857788:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
...
Shouldn’t they run only 2 times, because they will be iterated two times only?
This is what I’m getting:
c:\Users\Antonio\Downloads\IBM-Developer\Node.js\Course\Unit-5>node example5.js
1574098192618:INFO: MAINLINE: START
1574098192623:INFO: MAINLINE: END
1574098192624:INFO: MAINLINE MICROTASK: process.nextTick
1574098192625:INFO: TIMERS PHASE: START iteration 0: setInterval
1574098192628:INFO: TIMERS PHASE: END iteration 0: setInterval
1574098192629:INFO: CHECK PHASE: setInterval.setImmediate
1574098192629:INFO: CHECK PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574098192629:INFO: TIMERS PHASE: TIMER EXPIRED (from iteration 0): setInterval.setTimeout
1574098192630:INFO: TIMERS PHASE: START iteration 1: setInterval
1574098192630:INFO: TIMERS PHASE: END iteration 1: setInterval
1574098192633:INFO: TIMERS PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574098192634:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1574098192634:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1574098192634:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1574098192634:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1574098192635:INFO: CHECK PHASE: setInterval.setImmediate
1574098192646:INFO: CHECK PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574098192646:INFO: TIMERS PHASE: TIMER EXPIRED (from iteration 1): setInterval.setTimeout
1574098192652:INFO: TIMERS PHASE: START iteration 2: setInterval
1574098192652:INFO: TIMERS PHASE: Max interval count exceeded. Goodbye.
1574098192681:INFO: TIMERS PHASE: END iteration 2: setInterval
1574098192682:INFO: TIMERS PHASE MICROTASK: setInterval.setTimeout.process.nextTick
c:\Users\Antonio\Downloads\IBM-Developer\Node.js\Course\Unit-5>node -v
v10.16.3
As you can see I’m running node version 10.16.3, but I hope, It shouldn’t be that different.
Thank you.
Kind Regards.
Hello Antonio,
I’m glad you are enjoying the Learning Path!
You are correct, this is definitely an error, but it’s not in the code, rather in the content for Unit 5 itself. This is most likely a copy/paste mistake that I made when producing the content for that unit, and just never caught it.
I’ll contact IBM and get someone to make the correction ASAP. There should only be two sets of output from the microtask.
Just like you, Here’s what I get:
1574105413757:INFO: MAINLINE: START
1574105413759:INFO: MAINLINE: END
1574105413760:INFO: MAINLINE MICROTASK: process.nextTick
1574105413760:INFO: TIMERS PHASE: START iteration 0: setInterval
1574105413761:INFO: TIMERS PHASE: END iteration 0: setInterval
1574105413761:INFO: TIMERS PHASE: TIMER EXPIRED (from iteration 0): setInterval.setTimeout
1574105413761:INFO: TIMERS PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574105413762:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1574105413762:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1574105413762:INFO: CHECK PHASE: setInterval.setImmediate
1574105413762:INFO: CHECK PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574105413762:INFO: TIMERS PHASE: START iteration 1: setInterval
1574105413762:INFO: TIMERS PHASE: END iteration 1: setInterval
1574105413762:INFO: CHECK PHASE: setInterval.setImmediate
1574105413762:INFO: CHECK PHASE MICROTASK: setInterval.setTimeout.process.nextTick
1574105413762:INFO: POLL PHASE: fs.readdir() callback: Directory contains: 8 files
1574105413762:INFO: POLL PHASE MICROTASK: setInterval.fs.readdir.process.nextTick
1574105413764:INFO: TIMERS PHASE: TIMER EXPIRED (from iteration 1): setInterval.setTimeout
1574105413764:INFO: TIMERS PHASE: START iteration 2: setInterval
1574105413764:INFO: TIMERS PHASE: Max interval count exceeded. Goodbye.
1574105413764:INFO: TIMERS PHASE: END iteration 2: setInterval
1574105413764:INFO: TIMERS PHASE MICROTASK: setInterval.setTimeout.process.nextTick
If you find any other mistakes, please log an issue to the GitHub repo at: https://github.com/jstevenperry/IBM-Developer
Thanks for reporting this, and thanks so much for reading!
–jsp