From 459223f4b6703188c92aabb2b34c5eaf16896e4e Mon Sep 17 00:00:00 2001 From: Rafael Sobral Date: Fri, 21 Jan 2022 18:07:23 -0300 Subject: [PATCH] =?UTF-8?q?P=C3=ACpe=20parse=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- decoder.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/decoder.js b/decoder.js index 248988a..28e83ba 100644 --- a/decoder.js +++ b/decoder.js @@ -28,16 +28,20 @@ Decoder.prototype._write = function (chunk, encoding, cb) { } Decoder.prototype._writeOffset = function (chunk, offset, cb) { - while (offset < chunk.length) { - debug('decoding chunk', util.inspect(chunk.slice(offset).toString())) - if (this._inBody) { - offset = this._writeBody(chunk, offset, cb) - if (offset === 0) return // chunk not consumed - _writeOffset will be called again when ready - } else { - offset = this._writeHead(chunk, offset) + try { + while (offset < chunk.length) { + debug('decoding chunk', util.inspect(chunk.slice(offset).toString())) + if (this._inBody) { + offset = this._writeBody(chunk, offset, cb) + if (offset === 0) return // chunk not consumed - _writeOffset will be called again when ready + } else { + offset = this._writeHead(chunk, offset) + } } + cb() + } catch (err) { + cb(err); } - cb() } Decoder.prototype._writeHead = function (chunk, offset) {