diff --git a/app/routes/leagues/$leagueId.draft.$seasonId.tsx b/app/routes/leagues/$leagueId.draft.$seasonId.tsx index 52846c1..ac58bd3 100644 --- a/app/routes/leagues/$leagueId.draft.$seasonId.tsx +++ b/app/routes/leagues/$leagueId.draft.$seasonId.tsx @@ -271,10 +271,14 @@ export default function DraftRoom() { }, [reconnectCount, revalidate]); // Guard against Clerk JWT expiry race: if the loader ran without a userId (expired - // short-lived JWT) but the Clerk client SDK has a valid session, revalidate so the - // loader re-runs with a fresh token and returns correct userTeam/userQueue data. + // short-lived JWT) but the Clerk client SDK has a valid session, revalidate once so + // the loader re-runs with a fresh token and returns correct userTeam/userQueue data. + // The ref prevents an infinite loop if the server consistently fails to return a + // userId (e.g. misconfigured secret key) — we only attempt this recovery once. + const authRevalidatedRef = useRef(false); useEffect(() => { - if (clerkUserId && !currentUserId) { + if (clerkUserId && !currentUserId && !authRevalidatedRef.current) { + authRevalidatedRef.current = true; revalidate(); } }, [clerkUserId, currentUserId, revalidate]);