From 9f88068d778e8474907ebc192fce3c55554294e3 Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Wed, 10 Jun 2026 16:52:47 -0400 Subject: [PATCH] fix(06): WR-05 also match SessionExpiredError by name across module-graph boundaries --- apps/pwa/src/main.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) } }