mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
This commit is contained in:
@@ -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<T>(
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user