tju-yxq opened a new issue, #5541:
URL: https://github.com/apache/rocketmq-dashboard/issues/5541

   ## Problem
   
   A sweep of every `useEffect`/`useCallback` in `web/src` (233 non-test files) 
against the codebase's own dominant pattern — a 
`cancelled`/`requestId`/`mounted` guard around async `setState`, or a cleanup 
that clears scheduled timers — finds six stragglers. Five of the six are 
`setState`-after-unmount windows (harmless-looking React 18 no-ops, but exactly 
the class the rest of the codebase systematically guards); one is a real 
stale-data overwrite on a live page:
   
   1. **`ops/alerts.tsx` (the real bug)** — in the rule-loading effect, the 
sibling `listAlertRulesPage` call is fully guarded by the effect's `cancelled` 
flag, but `listAlertRuleRuntime(domain).then(setRuntime)` is not. The effect 
re-runs on every domain/filter/page/search change: a slow runtime response for 
a previous domain can resolve **after** the switch and clobber the new domain's 
runtime state. The guard already exists in scope; the call just doesn't use it.
   2. **`ops/alerts.tsx`** — the mount-only `listInstances()` effect has no 
`cancelled` flag and no cleanup.
   3. **`cluster/index.tsx`** — the failure path schedules a 3s retry with 
`window.setTimeout(() => setInstanceLoadKey(...))` that is never captured or 
cleared; navigating away within the 3s window fires the state update after 
unmount.
   4. **`ai/components/ToolPlaygroundModal.tsx`** — `bootstrap()` guards the 
tool-catalog load with a request ref, but its cluster-list portion 
(`listClusters()` → 
`setClusterOptions`/`setSelectedClusterId`/`setClustersLoading`) has no guard 
and the effect has no cleanup.
   5. **`ai/components/AssistantBubble.tsx`** — the copy action schedules 
`setTimeout(() => setCopied(false), 2000)` that is never cleared; rapid 
re-copies also stack timers.
   6. **`components/MetricsExplorer.tsx`** — the de-registered-data-source 
effect schedules a `setTimeout(..., 0)` with no cleanup return.
   
   Every other timer/interval/fetch effect in the repo was verified to follow 
the guarded pattern (the audit's DEFENSIBLE list covers ~40 sites); these six 
are the complete set of exceptions.
   
   ## Expected behavior
   
   All async state writes and scheduled timers follow the codebase's 
established guard/cleanup pattern: a slow or late response from a superseded 
context never overwrites newer state, and nothing fires after unmount.
   


-- 
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