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)); } }