Skip to content

Commit

Permalink
zlib: emits 'close' event after readable 'end'
Browse files Browse the repository at this point in the history
Call the close method after readable 'end' so that 'close' will be
emitted afterwards.

Fixes: #32023

PR-URL: #32050
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Sergey Zelenov authored and addaleax committed Mar 11, 2020
1 parent c41e360 commit 0c545f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c545f0

Please sign in to comment.