From b81aa36d0c9ef19210550765f78d4458f89329dd Mon Sep 17 00:00:00 2001 From: Christophe Diederichs <45171645+chm-diederichs@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:09:21 +0200 Subject: [PATCH] check that we have all catchup nodes locally (#162) * assert that we have all nodes locally * throw instead of asserting * emit warning and clear state if catchup fails * safetyCatch err in open * crash when block is not available locally --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4757fd1d..0163c7de 100644 --- a/index.js +++ b/index.js @@ -523,7 +523,10 @@ module.exports = class Autobase extends ReadyResource { if (length > w.end) w.end = length - const block = await w.writer.core.get(length - 1) + // we should have all nodes locally + const block = await w.writer.core.get(length - 1, { wait: false }) + + assert(block !== null, 'Catchup failed: local block not available') for (const dep of block.node.heads) { nodes.push(dep)