Files
Live_RC/src/local_cache.js
T
larssandandClaude Opus 5.5 2c6c37f6ca fix(decoder): connect even when the browser storage is full
A big installation outgrew the localStorage quota; saveState() threw
QuotaExceededError and, since connecting saves first, the decoder never
came online. The local copy is only a cache of the server state, so a
write that doesn't fit now drops it instead of throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 16:06:35 +02:00

16 lines
784 B
JavaScript

// The browser's localStorage copy of the state is only a cache: the server's SQLite state is the
// truth and every page load hydrates from it. A big installation (results, training ledger, logo)
// outgrows the ~5 MB quota, and setItem then throws - which used to abort whatever called
// saveState(), e.g. connecting the decoder. A cache that can't be written is dropped instead
// (the page then starts from the server like a fresh browser); a cut-down copy is never kept,
// since a partial state could be synced back over the server's.
export function writeLocalCache(storage, key, value) {
try {
storage.setItem(key, JSON.stringify(value));
return { ok: true };
} catch (error) {
try { storage.removeItem(key); } catch {}
return { ok: false, error };
}
}