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>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-18 16:06:35 +02:00
1 parent c8a797fe6f
commit 2c6c37f6ca
9 files changed
+99 -4

No files matched your search

+25
View File
@@ -34,6 +34,31 @@ export async function runDecoderUrlSmoke({ evaluate, navigate, savedState, waitF
} finally {
await second.close();
}
// A full browser storage (big installation: results, training ledger, logo) made every
// saveState() throw QuotaExceededError - and Connect saves before it connects, so the
// decoder never came online. The local copy is only a cache of the server state.
const third = await startFakeDecoder();
try {
const thirdUrl = `ws://127.0.0.1:${third.port}`;
await evaluate(`(() => {
window.__realSetItem = Storage.prototype.setItem;
Storage.prototype.setItem = function (key, value) {
if (key === "rc_timing_control_v1") throw new DOMException("Setting the value of '" + key + "' exceeded the quota.", "QuotaExceededError");
return window.__realSetItem.call(this, key, value);
};
const input = document.querySelector('#settingsForm [name="wsUrl"]');
input.value = ${JSON.stringify(thirdUrl)};
document.getElementById("settingsConnect").click();
})()`);
await waitFor(async () => third.totalConnections() > 0, "connects although the browser storage is full");
await waitFor(async () => (await savedState()).settings.wsUrl === thirdUrl, "and still saves to the server");
assert.equal(await evaluate(`localStorage.getItem("rc_timing_control_v1")`), null, "the stale local copy is dropped");
console.log("PASS a full browser storage no longer stops the decoder from connecting or saving to the server");
} finally {
await evaluate(`window.__realSetItem && (Storage.prototype.setItem = window.__realSetItem)`);
await third.close();
}
} finally {
const current = await savedState();
await fetch(base + "/api/state", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...current, settings: { ...current.settings, wsUrl: before.settings.wsUrl, autoReconnect: false } }) });