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:
parent
31e04d9c74
commit
9e822b2073
1 changed files with 11 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue