fix(sync): retry failed saves every 5 s; restart the decoder simulator with the server (1.65.5)

This commit is contained in:
larssand committed 2026-11-05 19:48:32 +01:00
1 parent fed83ddf67
commit 54f4c3b923
7 files changed
+44 -6

No files matched your search

+9 -1
View File
@@ -166,7 +166,15 @@ const hydrateFromBackend = ({ initial = false } = {}) => hydrateFromBackendHelpe
const isRunningRaceHere = () => !overlayMode && Boolean(getPrologueSession() || pendingStartSessionId || startsInProgress > 0
|| (state.decoder?.connected && state.sessions.some((session) => ["running", "paused"].includes(session.status))));
const scheduleBackendSync = () => scheduleBackendSyncHelper({ getBackendSyncTimer: () => backendSyncTimer, setBackendSyncTimer: (value) => { backendSyncTimer = value; }, syncStateToBackend });
const syncStateToBackend = () => syncStateToBackendHelper({ backend, t, getBackendUrl, buildPersistableState, getLocalStateVersion: () => localStateVersion, getSyncedStateVersion: () => syncedStateVersion, setSyncedStateVersion: (value) => { syncedStateVersion = value; }, getLocalStateDirty: () => localStateDirty, setLocalStateDirty: (value) => { localStateDirty = value; } });
const syncStateToBackendOnce = () => syncStateToBackendHelper({ backend, t, getBackendUrl, buildPersistableState, getLocalStateVersion: () => localStateVersion, getSyncedStateVersion: () => syncedStateVersion, setSyncedStateVersion: (value) => { syncedStateVersion = value; }, getLocalStateDirty: () => localStateDirty, setLocalStateDirty: (value) => { localStateDirty = value; } });
// A save that fails (server restarting, network gone) is tried again every 5 s until it gets
// through, so "Changes waiting to save" never hangs when nothing else changes.
let syncRetryTimer = null;
const syncStateToBackend = async () => {
await syncStateToBackendOnce();
clearTimeout(syncRetryTimer);
syncRetryTimer = backend.writeError && localStateDirty ? setTimeout(() => { if (!backend.pendingWrites) void syncStateToBackend(); }, 5000) : null;
};
const pingBackend = () => pingBackendHelper({ backend, t, getBackendUrl });
const checkAppVersion = () => checkAppVersionHelper({ onContact: (online) => {
backend.available = online;