Files
pulse/lib/utils/storage-cleanup.ts
Usman Baig 205cdf314c perf: bound SWR cache, clean stale storage, cap annotations
Add LRU cache provider (200 entries) to prevent unbounded SWR memory
growth. Clean up stale PKCE localStorage keys on app init. Cap chart
annotations to 20 visible reference lines with overflow indicator.
2026-03-10 21:19:33 +01:00

18 lines
593 B
TypeScript

// * Cleans up stale localStorage entries on app initialization
// * Prevents accumulation from abandoned OAuth flows
export function cleanupStaleStorage() {
if (typeof window === 'undefined') return
try {
// * PKCE keys are only needed during the OAuth callback
// * If we're not on the callback page, they're stale leftovers
if (!window.location.pathname.includes('/auth/callback')) {
localStorage.removeItem('oauth_state')
localStorage.removeItem('oauth_code_verifier')
}
} catch {
// * Ignore errors (private browsing, storage disabled, etc.)
}
}