fix: remove reload-based stale build recovery to stop login loop
window.location.reload() causes infinite loops when the CDN keeps serving cached assets. Instead, silently treat Server Action failures as no-session — the OAuth flow uses full navigations (window.location.href) which naturally fetch fresh content from the server on return.
This commit is contained in:
@@ -26,14 +26,7 @@ function AuthCallbackContent() {
|
|||||||
try {
|
try {
|
||||||
result = await exchangeAuthCode(code, codeVerifier, redirectUri)
|
result = await exchangeAuthCode(code, codeVerifier, redirectUri)
|
||||||
} catch {
|
} catch {
|
||||||
// * Stale build — cached JS has old Server Action hashes. Hard reload once to fix.
|
// * Stale build or network error — show error so user can retry via full navigation
|
||||||
const key = 'pulse_reload_for_stale_build'
|
|
||||||
if (!sessionStorage.getItem(key)) {
|
|
||||||
sessionStorage.setItem(key, '1')
|
|
||||||
window.location.reload()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sessionStorage.removeItem(key)
|
|
||||||
setError('Something went wrong. Please try logging in again.')
|
setError('Something went wrong. Please try logging in again.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,20 +135,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||||||
let session: Awaited<ReturnType<typeof getSessionAction>> = null
|
let session: Awaited<ReturnType<typeof getSessionAction>> = null
|
||||||
try {
|
try {
|
||||||
session = await getSessionAction()
|
session = await getSessionAction()
|
||||||
sessionStorage.removeItem('pulse_reload_for_stale_build')
|
|
||||||
} catch {
|
} catch {
|
||||||
// * Stale build — browser has cached JS with old Server Action hashes.
|
// * Stale build — treat as no session. The login page will redirect
|
||||||
// * Force a hard reload once to fetch fresh bundles. Guard prevents infinite loop.
|
// * to the auth service via window.location.href (full navigation),
|
||||||
const key = 'pulse_reload_for_stale_build'
|
// * which fetches fresh HTML/JS from the server on return.
|
||||||
if (!sessionStorage.getItem(key)) {
|
|
||||||
sessionStorage.setItem(key, '1')
|
|
||||||
window.location.reload()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sessionStorage.removeItem(key)
|
|
||||||
// * Reload didn't fix it — treat as no session
|
|
||||||
setLoading(false)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * 2. If no access_token but refresh_token may exist, try refresh (fixes 15-min inactivity logout)
|
// * 2. If no access_token but refresh_token may exist, try refresh (fixes 15-min inactivity logout)
|
||||||
@@ -162,15 +152,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||||||
try {
|
try {
|
||||||
session = await getSessionAction()
|
session = await getSessionAction()
|
||||||
} catch {
|
} catch {
|
||||||
const key = 'pulse_reload_for_stale_build'
|
// * Stale build — fall through as no session
|
||||||
if (!sessionStorage.getItem(key)) {
|
|
||||||
sessionStorage.setItem(key, '1')
|
|
||||||
window.location.reload()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sessionStorage.removeItem(key)
|
|
||||||
setLoading(false)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user