From a145ffdc68cedab6cb366274b7d971b03b184ffc Mon Sep 17 00:00:00 2001 From: ashim-hq Date: Tue, 21 Apr 2026 00:06:46 +0800 Subject: [PATCH] fix: trigger disconnected state when chunk loads exhaust retries When lazyWithRetry exhausts all retry attempts on a chunk error, also call setDisconnected() so the reconnecting banner appears alongside the ErrorBoundary's "Update Available" card. --- apps/web/src/lib/lazy-with-retry.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/web/src/lib/lazy-with-retry.ts b/apps/web/src/lib/lazy-with-retry.ts index 54991c61..a450f5c2 100644 --- a/apps/web/src/lib/lazy-with-retry.ts +++ b/apps/web/src/lib/lazy-with-retry.ts @@ -1,4 +1,5 @@ import { type ComponentType, lazy } from "react"; +import { useConnectionStore } from "@/stores/connection-store"; export function isChunkError(error: unknown): boolean { if (!(error instanceof Error)) return false; @@ -21,7 +22,12 @@ export async function retryDynamicImport( try { return await importFn(); } catch (error) { - if (!isChunkError(error) || attempt === retries) throw error; + if (!isChunkError(error) || attempt === retries) { + if (isChunkError(error)) { + useConnectionStore.getState().setDisconnected(); + } + throw error; + } await new Promise((resolve) => setTimeout(resolve, delay)); } }