Skip to content

Commit

Permalink
zlib: do not emit event on *Sync() methods
Browse files Browse the repository at this point in the history
WIP right now, still need to do it for more methods than just
gunzipSync().

Refs: nodejs#1668
  • Loading branch information
Trott committed Mar 19, 2016
1 parent 0eb3ed5 commit 9bd2e07
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ Zlib.prototype.flush = function(kind, callback) {
}
};

Zlib.prototype.close = function(callback) {
Zlib.prototype.close = function(callback, options) {
options = options || {};

if (callback)
process.nextTick(callback);

Expand All @@ -464,7 +466,9 @@ Zlib.prototype.close = function(callback) {

this._handle.close();

process.nextTick(emitCloseNT, this);
if (!options.sync) {
process.nextTick(emitCloseNT, this);
}
};

function emitCloseNT(self) {
Expand Down Expand Up @@ -535,12 +539,12 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
}

if (nread >= kMaxLength) {
this.close();
this.close(null, {sync: true});
throw new RangeError(kRangeErrorMessage);
}

var buf = Buffer.concat(buffers, nread);
this.close();
this.close(null, {sync: true});

return buf;
}
Expand Down

0 comments on commit 9bd2e07

Please sign in to comment.