diff --git a/index.js b/index.js index f8eb822..4680a28 100644 --- a/index.js +++ b/index.js @@ -768,11 +768,19 @@ Writer.prototype._maybeUpdateFeeds = function () { } Writer.prototype._decode = function (seq, buf, cb) { - var val = messages.Entry.decode(buf) + try { + var val = messages.Entry.decode(buf) + } catch (e) { + return cb(e) + } val[util.inspect.custom] = inspect val.seq = seq val.path = hash(val.key, true) - val.value = val.value && this._db._valueEncoding.decode(val.value) + try { + val.value = val.value && this._db._valueEncoding.decode(val.value) + } catch (e) { + return cb(e) + } if (this._feedsMessage && this._feedsLoaded === val.inflate) { this._maybeUpdateFeeds() @@ -834,7 +842,12 @@ Writer.prototype._loadFeeds = function (head, buf, cb) { function onfeeds (err, buf) { if (err) return cb(err) - done(messages.InflatedEntry.decode(buf)) + try { + var msg = messages.InflatedEntry.decode(buf) + } catch (e) { + return cb(e) + } + done(msg) } function done (msg) {