Skip to content

Commit f095e38

Browse files
Sergey ZelenovMylesBorins
authored andcommitted
zlib: emits 'close' event after readable 'end'
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]>
1 parent 5bc5161 commit f095e38

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/zlib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
274274
this._defaultFlushFlag = flush;
275275
this._finishFlushFlag = finishFlush;
276276
this._defaultFullFlushFlag = fullFlush;
277-
this.once('end', _close.bind(null, this));
277+
this.once('end', this.close);
278278
this._info = opts && opts.info;
279279
}
280280
ObjectSetPrototypeOf(ZlibBase.prototype, Transform.prototype);

test/parallel/test-zlib.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ zlib.createDeflateRaw({ windowBits: 8 });
171171
.pipe(zlib.createInflateRaw({ windowBits: 8 }))
172172
.on('data', (chunk) => reinflated.push(chunk))
173173
.on('end', common.mustCall(
174-
() => assert(Buffer.concat(raw).equals(Buffer.concat(reinflated)))));
174+
() => assert(Buffer.concat(raw).equals(Buffer.concat(reinflated)))))
175+
.on('close', common.mustCall(1));
175176
}
176177

177178
// For each of the files, make sure that compressing and

0 commit comments

Comments
 (0)