diff --git a/.travis.yml b/.travis.yml index 4485155..098fbc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,6 @@ node_js: - "4" - "5" - "6" + - "7" + - "8" + - "9" diff --git a/lib/parser-async.js b/lib/parser-async.js index e3e1a6b..b52d573 100644 --- a/lib/parser-async.js +++ b/lib/parser-async.js @@ -41,6 +41,14 @@ ParserAsync.prototype._handleError = function(err) { this._inflate.destroy(); } + if (this._filter) { + this._filter.destroy(); + // For backward compatibility with Node 7 and below. + // Suppress errors due to _inflate calling write() even after + // it's destroy()'ed. + this._filter.on('error', function() {}); + } + this.errord = true; }; diff --git a/lib/sync-inflate.js b/lib/sync-inflate.js index 26c5b2f..c3aecc9 100644 --- a/lib/sync-inflate.js +++ b/lib/sync-inflate.js @@ -17,6 +17,10 @@ function Inflate(opts) { zlib.Inflate.call(this, opts); + // Node 8 --> 9 compatibility check + this._offset = this._offset === undefined ? this._outOffset : this._offset; + this._buffer = this._buffer || this._outBuffer; + if (opts && opts.maxLength != null) { this._maxLength = opts.maxLength; } @@ -110,6 +114,8 @@ Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) { this._buffer, // out this._offset, //out_off availOutBefore); // out_len + // Node 8 --> 9 compatibility check + res = res || this._writeState; } while (!this._hadError && handleChunk(res[0], res[1])); if (this._hadError) {