Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumNodeJSprocess.nextTick vs setImmediateSingle-choice MCQ

Inside a single `process.nextTick` callback you call `process.nextTick` again, and that one schedules another, and so on for 10,000 iterations. Meanwhile a `setImmediate` and an I/O callback are also pending. In what order does Node drain this?

process.nextTick(function tick(n) { if (n > 0) process.nextTick(tick, n - 1); }); setImmediate(() => console.log('immediate')); require('node:fs').readFile(__filename, () => console.log('io'));