RustyMarvin / line-by-line

A NodeJS module that helps you reading large text files, line by line, without buffering the files into memory.
MIT License
42 stars 39 forks source link

Replace recursive process.nextTick usage with setImmediate #4

Open itpmngt opened 10 years ago

itpmngt commented 10 years ago

As per http://blog.nodejs.org/2013/03/11/node-v0-10-0-stable/

You've got a recursive process.nextTick happening in line-by-line - and we're seeing this crash node occasionally with:

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral. (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral. (node) warning: Recursive process.nextTick detected. This will break in the next . version of node. Please use setImmediate for recursive deferral. (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.......... RangeError: Maximum call stack size exceeded

More info here: http://blog.peakji.com/node-js-process-nexttick-and-setimmediate/

And because setImmediate is not available in previous 'node' would be good to have a fallback like:

if (typeof setImmediate == 'undefined') { var setImmediate = process.nextTick; }

Great plugin - Thank You