From 82e82418c975ea2e5e166a09e0c13aac1477034d Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Mon, 29 Jul 2024 13:35:54 +0100 Subject: [PATCH 1/3] only set local length if lookup succeeds --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index c11953a0..f7082a5a 100644 --- a/index.js +++ b/index.js @@ -1638,8 +1638,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 = [] From a8581b4f993a3189c8f676eb1cb377887cfc73b4 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Mon, 29 Jul 2024 13:37:32 +0100 Subject: [PATCH 2/3] catch lookup error --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index f7082a5a..b57a094a 100644 --- a/index.js +++ b/index.js @@ -1637,6 +1637,8 @@ module.exports = class Autobase extends ReadyResource { await Promise.all(promises) if (localLookup) { + localLookup.catch(emitWarning) + const value = await localLookup if (value) info.localLength = value.isRemoved ? -1 : value.length } From 90f2f0deb1e7d2e1b62cd53d38cb2845e8c53d04 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Mon, 29 Jul 2024 13:39:34 +0100 Subject: [PATCH 3/3] catch after making promise --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index b57a094a..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 = [] @@ -1637,8 +1638,6 @@ module.exports = class Autobase extends ReadyResource { await Promise.all(promises) if (localLookup) { - localLookup.catch(emitWarning) - const value = await localLookup if (value) info.localLength = value.isRemoved ? -1 : value.length }