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.
This commit is contained in:
17
lib/utils/storage-cleanup.ts
Normal file
17
lib/utils/storage-cleanup.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// * 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.)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user