mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
fix: stop dashboard sidebar infinite refetch loop (#2564)
## Summary - Fix infinite refetch loop in the dashboard sidebar that fires hundreds of POST+GET requests per second - The `subscriptionFetchRef` was reset in `finally()`, allowing re-entrancy: fetch → `setSubscription` → re-render → ref is `false` → fetch again → infinite loop - Move the ref reset to the effect cleanup function so it only resets when `mode` actually changes ## Note: Auth0 favicon 404 The Auth0 login page at `codeflash-ai.us.auth0.com` returns a 404 for `/favicon.ico`. This is configured in **Auth0 Dashboard > Branding > Universal Login**, not in application code. Upload the Codeflash favicon there to resolve. ## Test plan - [ ] Navigate to dashboard, open Network tab — confirm no repeated POST/GET polling - [ ] Switch between personal/org mode — confirm subscription data still loads correctly - [ ] Verify sidebar subscription usage display still renders
This commit is contained in:
parent
f6a7d9b29d
commit
c8a66b5ec6
2 changed files with 9 additions and 3 deletions
|
|
@ -106,8 +106,10 @@ export function Sidebar({ className, user, isLoading, error }: SidebarProps): JS
|
|||
if (subscriptionFetchRef.current) return
|
||||
subscriptionFetchRef.current = true
|
||||
|
||||
let cancelled = false
|
||||
getCurrentUserSubscriptionData()
|
||||
.then(data => {
|
||||
if (cancelled) return
|
||||
if (data) {
|
||||
setSubscription({
|
||||
optimizations_used: data.optimizations_used || 0,
|
||||
|
|
@ -117,10 +119,14 @@ export function Sidebar({ className, user, isLoading, error }: SidebarProps): JS
|
|||
setSubscription(null)
|
||||
}
|
||||
})
|
||||
.catch(() => setSubscription(null))
|
||||
.finally(() => {
|
||||
subscriptionFetchRef.current = false
|
||||
.catch(() => {
|
||||
if (!cancelled) setSubscription(null)
|
||||
})
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
subscriptionFetchRef.current = false
|
||||
}
|
||||
}, [mode])
|
||||
|
||||
const toggleTheme = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue