From 8622da2ba49a1e3562c6b81041aadc5d11066a82 Mon Sep 17 00:00:00 2001 From: Jason Tudisco Date: Mon, 25 May 2026 13:18:33 -0600 Subject: [PATCH] fix(kez-chat/web): snapshot envelope before storing in IndexedDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Save claim was silently failing — button click did nothing. Cause: \`envelope\` lives in \$state, which wraps the value in a deep Proxy; idb-keyval calls structuredClone internally, which can't clone proxies and throws DataCloneError. Without a try/catch the error vanished into the console and the step transition never ran. - Pass \$state.snapshot(envelope) to addClaim so IDB sees a plain object. - Wrap in try/catch + alert so future IDB failures surface to the user instead of dying silently. Co-Authored-By: Claude Opus 4.7 --- kez-chat/web/src/routes/AddClaim.svelte | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/kez-chat/web/src/routes/AddClaim.svelte b/kez-chat/web/src/routes/AddClaim.svelte index ae5470b..18dc69c 100644 --- a/kez-chat/web/src/routes/AddClaim.svelte +++ b/kez-chat/web/src/routes/AddClaim.svelte @@ -180,12 +180,20 @@ async function saveAndDone() { if (!envelope || !selected) return; - await addClaim({ - id: crypto.randomUUID(), - envelope, - channel: selected.key, - }); - step = "done"; + try { + // $state wraps `envelope` in a deep Proxy; structuredClone (used + // by idb-keyval) can't clone proxies and throws DataCloneError. + // $state.snapshot returns a plain, cloneable object. + await addClaim({ + id: crypto.randomUUID(), + envelope: $state.snapshot(envelope) as SignedClaimEnvelope, + channel: selected.key, + }); + step = "done"; + } catch (e) { + console.error("saveAndDone failed", e); + alert(`Failed to save claim: ${(e as Error).message}`); + } }