From df84165ca37d77c8e251a65157e0aedf65226cf0 Mon Sep 17 00:00:00 2001 From: steelsojka Date: Fri, 22 Nov 2013 16:21:22 -0600 Subject: [PATCH] fix(chunkstream): max call stack thrown when parsing large pngs --- lib/chunkstream.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/chunkstream.js b/lib/chunkstream.js index e8ddac5..e57c1e7 100755 --- a/lib/chunkstream.js +++ b/lib/chunkstream.js @@ -48,14 +48,16 @@ ChunkStream.prototype.read = function(length, callback) { func: callback }); - this._process(); + process.nextTick(function() { + this._process(); - // its paused and there is not enought data then ask for more - if (this._paused && this._reads.length > 0) { - this._paused = false; + // its paused and there is not enought data then ask for more + if (this._paused && this._reads.length > 0) { + this._paused = false; - this.emit('drain'); - } + this.emit('drain'); + } + }.bind(this)); }; ChunkStream.prototype.write = function(data, encoding) {