change process.nextTick to setImmediate.

Node warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.