zlib: emits 'close' event after readable 'end'

Call the close method after readable 'end' so that 'close' will be
emitted afterwards.

Fixes: https://github.com/nodejs/node/issues/32023

PR-URL: https://github.com/nodejs/node/pull/32050
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Sergey Zelenov
2020-03-02 17:02:08 +01:00
committed by Anna Henningsen
parent c41e360de7
commit 0c545f0f72
2 changed files with 3 additions and 2 deletions

View File

@@ -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);

View File

@@ -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