Difference between process.nextTick and setImmediate in NodeJS

In a funny deviation from what the name suggests, setImmediate is a callback that will be made after the nextTick() calls! The setImmediate by definition happens after current execution and after timer & I/O events, while the process.nextTick calls will be called after current script execution and before other timer & I/O Events!

So an Disk I/O event handler set in setImmediate has a flimsy chance that it might not be called, while the one set in process.nextTick is sure to be called!

Leave a Reply

%d bloggers like this: