fix(06): WR-05 also match SessionExpiredError by name across module-graph boundaries

This commit is contained in:
Lucas Berger
2026-06-10 16:52:47 -04:00
parent 746c3c70d7
commit 9f88068d77
+8 -1
View File
@@ -28,7 +28,14 @@ import { useCalendarStore } from './store/calendarStore.js'
* Confirmed via Context7 /tanstack/query docs for v5.101.0. * Confirmed via Context7 /tanstack/query docs for v5.101.0.
*/ */
function onGlobalError(error: unknown): void { 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) useCalendarStore.getState().setSessionExpired(true)
} }
} }