From dddc01dd36097549a1071de845a653e4c393abe0 Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Mon, 3 Mar 2025 14:11:43 -0800 Subject: [PATCH] bug: The `vat.terminated` table is not always there. check first. --- packages/synthetic-chain/src/lib/vat-status.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/synthetic-chain/src/lib/vat-status.js b/packages/synthetic-chain/src/lib/vat-status.js index 0c455dbc..cfc5d94d 100644 --- a/packages/synthetic-chain/src/lib/vat-status.js +++ b/packages/synthetic-chain/src/lib/vat-status.js @@ -37,6 +37,7 @@ const makeSwingstoreTool = db => { /** @param {string} key */ // @ts-expect-error sqlite typedefs const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value; + const kvGetSafe = key => sql.get`select * from kvStore where key = ${key}`; /** @param {string} key */ const kvGetJSON = key => JSON.parse(kvGet(key)); @@ -48,6 +49,10 @@ const makeSwingstoreTool = db => { currentSpan: () => sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`, terminated: () => { + const t = kvGetSafe('vat.terminated'); + if (!t) { + return false; + } const terminatedIDs = kvGetJSON('vat.terminated'); return terminatedIDs.some(terminatedID => vatID === terminatedID); },