diff --git a/apps/pwa/src/main.tsx b/apps/pwa/src/main.tsx index dd5c0ab..4f22a91 100644 --- a/apps/pwa/src/main.tsx +++ b/apps/pwa/src/main.tsx @@ -28,7 +28,14 @@ import { useCalendarStore } from './store/calendarStore.js' * Confirmed via Context7 /tanstack/query docs for v5.101.0. */ function onGlobalError(error: unknown): void { - if (error instanceof SessionExpiredError) { + // WR-05: instanceof can fail if client.ts is ever loaded through two module graphs + // (Vite SSR, duplicated chunk, or the tests' repeated `await import('./client.js')`), + // leaving the session-expiry interstitial unarmed. SessionExpiredError carries a fixed + // `name` for identity stability, so also check that defensively. + if ( + error instanceof SessionExpiredError || + (error as { name?: string } | null)?.name === 'SessionExpiredError' + ) { useCalendarStore.getState().setSessionExpired(true) } }