I\'m having trouble understanding exactly how process.nextTick
does its thing. I thought I understood, but I can\'t seem to replicate how I feel this should wor
process.nextTick put the callback on the next tick that is going to be executed, not at the end of the tick queue.
Node.js doc (http://nodejs.org/api/process.html#process_process_nexttick_callback) say: "It typically runs before any other I/O events fire, but there are some exceptions."
setTimeout(callback, 0) will probably work more like you describe.
You should certainly read the link fgascon provided, and perhaps
https://github.com/joyent/node/issues/3335 for more background.
Use process.nextTick for when you want to call some code before any IO, but after the calling context has returned (usually because you want to register listeners on an event emitter and need to return the created emitter before you can register anything).