diff --git a/lib/zlib.js b/lib/zlib.js index 1151b2cb88..82b08018e7 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -444,10 +444,9 @@ Zlib.prototype.flush = function(kind, callback) { if (callback) this.once('end', callback); } else if (ws.needDrain) { - var self = this; - this.once('drain', function() { - self.flush(kind, callback); - }); + if (callback) { + this.once('drain', () => this.flush(kind, callback)); + } } else { this._flushFlag = kind; this.write(new Buffer(0), '', callback);