fix(06): WR-05 also match SessionExpiredError by name across module-graph boundaries
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user