fix: recover gracefully from stale Server Action hashes after deployment

Wrap all Server Action calls (getSessionAction, exchangeAuthCode,
logoutAction) in try-catch so a cached browser bundle with old action
IDs triggers a hard reload instead of an infinite loading spinner.
This commit is contained in:
Usman Baig
2026-03-07 19:37:41 +01:00
parent cc268c320e
commit d2dfe62993
3 changed files with 25 additions and 4 deletions

View File

@@ -22,7 +22,14 @@ function AuthCallbackContent() {
const codeVerifier = localStorage.getItem('oauth_code_verifier')
const redirectUri = typeof window !== 'undefined' ? window.location.origin + '/auth/callback' : ''
if (!code) return
const result = await exchangeAuthCode(code, codeVerifier, redirectUri)
let result: Awaited<ReturnType<typeof exchangeAuthCode>>
try {
result = await exchangeAuthCode(code, codeVerifier, redirectUri)
} catch {
// * Stale build — cached JS has old Server Action hashes. Hard reload to fix.
window.location.reload()
return
}
if (result.success && result.user) {
// * Fetch full profile (including display_name) before navigating so header shows correct name on first paint
try {