Official node docs explain the following:
the nextTickQueue will be processed after the current operation completes, regardless of the current phase of the event loop.
With this in mind, I tested process.nextTick()
the following way:
const heapdump = require('heapdump');
let count = 0;
function snapshot(){
setTimeout(() => heapdump.writeSnapshot(), 5000)
}
process.nextTick(snapshot);
while(true){
count++
console.log(count);
}
My intention is to have process.nextTick(snapshot);
forcefully include the snapshot function into the event loop, calling itself during the infinite while
loop.
Why does this not happen?