RockteMQ-AI commented on issue #2901:
URL: 
https://github.com/apache/rocketmq-dashboard/issues/2901#issuecomment-5496828083

   **Issue Evaluation**
   
   Category: `bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase.
   
   **Root Cause:** The `useVisiblePolling` hook stores its in-flight flag (`e`) 
inside the `useEffect` closure. When the component rerenders with a new poll 
callback `r`, the effect dependencies `[t, n, r]` trigger a cleanup and 
recreation. The new effect closure starts with a fresh `e = false`, while the 
previous promise from the old closure may still be pending. This allows the 
interval or visibility handler to fire a concurrent poll before the original 
completes.
   
   **Impact:** Overlapping poll requests can cause race conditions, duplicate 
API calls, and inconsistent UI state in the BrokerCluster view.
   
   **Severity:** medium
   
   **Suggested fix:** Lift the in-flight flag out of the effect closure using a 
`useRef` so it persists across effect re-creations:
   ```js
   const inFlightRef = useRef(false);
   useEffect(() => {
     if (!enabled) return;
     const tick = () => {
       if (document.visibilityState !== "visible" || inFlightRef.current) 
return;
       inFlightRef.current = true;
       Promise.resolve().then(callback).catch(() => {}).finally(() => { 
inFlightRef.current = false; });
     };
     // ... interval + visibility listener
   }, [enabled, interval, callback]);
   ```
   
   An automated fix proposal will be generated. Reply `/approve` to proceed 
with PR generation.
   
   ---
   *Automated evaluation by RockteMQ-AI*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to