mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
zlib: only apply drain listener if given callback
When stream.flush() is called without a callback, an empty listener is being added. Since flush may be called multiple times to push SSE's down to the client, multiple noop listeners are being added. This in turn causes the memory leak detected message. PR-URL: https://github.com/nodejs/node/pull/3534 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
ce7039a209
commit
0a8e8d976a
1 file changed
+3
-4
+3
-4
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user