fix: handle non-ok HTTP responses in connection store checkHealth

checkHealth previously ignored non-ok responses (e.g. 503), silently
doing nothing when the server reported unhealthy. Add else branch to
transition connected → disconnected on non-ok status. Add tests for
connected → disconnected on fetch failure and offline → reconnected
on health check success.
This commit is contained in:
ashim-hq
2026-04-20 21:49:22 +08:00
parent c4dd55ace0
commit 2ba7520dd4
2 changed files with 22 additions and 0 deletions
+4
View File
@@ -51,6 +51,10 @@ export const useConnectionStore = create<ConnectionState>((set, get) => ({
} else {
set({ lastHealthCheck: Date.now() });
}
} else {
if (get().status === "connected") {
get().setDisconnected();
}
}
} catch {
if (get().status === "connected") {