Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/protocol/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ Stream.prototype._writeUpstream = function _writeUpstream(frame) {
return moreNeeded;
};

var inflateStatusToName = {
"0": "Z_OK",
"1": "Z_STREAM_END",
"2": "Z_SYNC_FLUSH",
"-1": "ERRNO",
"-2": "STREAM_ERROR",
"-3": "DATA_ERROR",
"-4": "MEM_ERROR"
};

// The `_receive` method (= `upstream._receive`) gets called when there's an incoming frame.
Stream.prototype._receive = function _receive(frame, ready) {
// * If it's a DATA frame, then push the payload into the output buffer on the other side.
Expand All @@ -296,6 +306,14 @@ Stream.prototype._receive = function _receive(frame, ready) {
}
var data = frame.data;
this.pakoInf.push(data, frame.END_STREAM);

if (this.pakoInf.err < 0) {
var statusName = inflateStatusToName[this.pakoInf.err];
var inflateError = new Error('Inflate frame failed with status ' + statusName);
this._log.error(inflateError, inflateError.message);
this.reset(inflateError);
this.emit('error', inflateError);
}
}
else
{
Expand Down