diff --git a/src/App.svelte b/src/App.svelte index 0a8ec5b..0114954 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -116,6 +116,7 @@ let authBusy = false; let connectionNotice = ''; let connectionCheckRunning = false; + let connectionCheckGeneration = 0; let realtimeState = 'DISCONNECTED'; let realtimeSocket: WebSocket | undefined; let activityEvents: Array<{ event_id: string; event_type: string; occurred_at: string }> = []; @@ -277,7 +278,7 @@ } async function checkServer() { - if (connectionCheckRunning) return; + const generation = ++connectionCheckGeneration; connectionCheckRunning = true; connectionState = 'CONNECTING'; let attempt = 0; @@ -290,6 +291,7 @@ } else { connectionNotice = 'Connecting to server'; } + if (generation !== connectionCheckGeneration) return; try { const response = await fetch(`${serverAddress}/api/v1/server/info`); if (!response.ok) throw new Error(`HTTP ${response.status}`);