diff --git a/lib/zlib.js b/lib/zlib.js index a707d817bbc8b5..d25b98e1ba047e 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -274,7 +274,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) { this._defaultFlushFlag = flush; this._finishFlushFlag = finishFlush; this._defaultFullFlushFlag = fullFlush; - this.once('end', _close.bind(null, this)); + this.once('end', this.close); this._info = opts && opts.info; } ObjectSetPrototypeOf(ZlibBase.prototype, Transform.prototype); diff --git a/test/parallel/test-zlib.js b/test/parallel/test-zlib.js index 509dcd2207e83e..0d21cf6cc29e58 100644 --- a/test/parallel/test-zlib.js +++ b/test/parallel/test-zlib.js @@ -171,7 +171,8 @@ zlib.createDeflateRaw({ windowBits: 8 }); .pipe(zlib.createInflateRaw({ windowBits: 8 })) .on('data', (chunk) => reinflated.push(chunk)) .on('end', common.mustCall( - () => assert(Buffer.concat(raw).equals(Buffer.concat(reinflated))))); + () => assert(Buffer.concat(raw).equals(Buffer.concat(reinflated))))) + .on('close', common.mustCall(1)); } // For each of the files, make sure that compressing and