solution_challenge_backend / fixes /applied_changes_frontend.md
github-actions
Deploy to Hugging Face
c794b6b
|
Raw
History Blame Contribute Delete
1.27 kB
# Applied Frontend Fixes
## 1. Fixed "Thundering Herd" Exponential Polling Issue
**File**: cepheus/src/hooks/useCommandApiStatus.js
**Issue**: When the backend became unavailable, the polling setInterval continued to fire every 5 seconds. Every iteration that failed launched an independent setTimeout backoff timer, which in turn spawned more polling callbacks. This resulted in exponential concurrent timers overloading the browser.
**Fix**: Replaced the competing setInterval and setTimeout design with a unified, recursive setTimeout loop. The interval properly suspends its natural cycle while backoff retries are active, preventing timer multiplication and strictly enforcing the backoff mechanism.
## 2. Fixed React Memory Leak (Unmounted State Updates)
**File**: cepheus/src/components/AlertFeed.jsx
**Issue**: The component used a setInterval that triggered a nested setTimeout to update state (for the UI ticker). The cleanup function properly cleared the setInterval but failed to clear the setTimeout, causing attempts to update React state on an unmounted component.
**Fix**: Captured the timeoutId inside the useEffect scope and explicitly added clearTimeout(timeoutId) to the component's cleanup function, resolving the zombie state update and memory leak.