Keep session alive during long drafts with a 15-minute ping

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-04-24 23:27:52 -07:00
parent 31e04d9c74
commit 9e822b2073

View file

@ -118,6 +118,17 @@ export function useDraftAuthRecovery({
};
}, [currentUserId, authDegraded, revalidate]);
// Periodically ping the session endpoint to keep it alive during long drafts.
useEffect(() => {
if (authDegraded) return;
const FIFTEEN_MINUTES = 15 * 60 * 1000;
const id = setInterval(async () => {
const { data: session } = await authClient.getSession();
if (!session) setAuthDegraded(true);
}, FIFTEEN_MINUTES);
return () => clearInterval(id);
}, [authDegraded]);
// Track revalidation lifecycle to sync local state from fresh loader data.
const revalidatorStateRef = useRef(revalidatorState);
const isRevalidatingRef = useRef(false);