fix(kez-chat/web): snapshot envelope before storing in IndexedDB
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 <noreply@anthropic.com>
This commit is contained in:
parent
17d68dbb75
commit
8622da2ba4
@ -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}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user