Skip to content

Commit b460af3

Browse files
committed
feat: end early if format ends early
Signal the end of data when format emits 'end' so that early 'end' (e.g. due to data after compressed data ends since nodejs/node#26363) so that InflateAuto behaves the same as the zlib streams. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
1 parent 12f536a commit b460af3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,13 @@ InflateAuto.prototype.setFormat = function setFormat(Format) {
630630
}
631631

632632
format.on('data', (chunk) => this.push(chunk));
633+
format.once('end', (chunk) => {
634+
// format may emit 'end' before 'finish' (and before .end() is called)
635+
// when there is data after the end of compressed input.
636+
// https://github.com/nodejs/node/pull/26363
637+
// Call push(null) to end this stream when the format has ended.
638+
this.push(null); // eslint-disable-line unicorn/no-null
639+
});
633640
// Note: Readable.wrap proxies 'destroy' event. No current use is known, but
634641
// we proxy it here for compatibility with non-Zlib formats.
635642
format.on('destroy', (...args) => this.emit('destroy', ...args));

0 commit comments

Comments
 (0)