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 <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Sergey Zelenov authored and MylesBorins committed Mar 11, 2020
1 parent 5bc5161 commit f095e38
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

2 comments on commit f095e38

@ronag
Copy link
Member

@ronag ronag commented on f095e38 Mar 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MylesBorins I'm a novice on git bisect but I think this breaks CI on v13.x-staging.

@MylesBorins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've backed out of 13.x for now, you will want to rebase you backports

Please # to comment.