From 17acfd85d15044cfb89653f0ba67255d1d072fc5 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs <45171645+chm-diederichs@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:48:43 +0200 Subject: [PATCH] only set local length if lookup succeeds (#165) * only set local length if lookup succeeds * catch lookup error * catch after making promise --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c11953a0..6351b3e0 100644 --- a/index.js +++ b/index.js @@ -1599,6 +1599,7 @@ module.exports = class Autobase extends ReadyResource { !system.sameIndexers(this.linearizer.indexers) const localLookup = this.localWriter ? system.get(this.local.key, { timeout }) : null + if (localLookup) localLookup.catch(noop) const indexers = [] const pendingViews = [] @@ -1638,8 +1639,7 @@ module.exports = class Autobase extends ReadyResource { if (localLookup) { const value = await localLookup - if (value) info.localLength = value.length - if (value.isRemoved) info.localLength = -1 + if (value) info.localLength = value.isRemoved ? -1 : value.length } const closing = []