ai-yang opened a new issue, #680:
URL: https://github.com/apache/rocketmq-dashboard/issues/680

   ### Baseline
   
   `rocketmq-studio` at `e012ecc69bd7cd4ad80a7028fa1385e97828fc16`.
   
   ### Problem
   
   The `/cluster` page labels its default two-second behavior as live 
auto-refresh, but the timer never calls `listClusters()`. Instead, it mutates 
Broker TPS and Proxy connection counts with `Math.random()` in the browser. 
This fabricates operational data, leaves cluster topology/configuration stale, 
and makes tests nondeterministic.
   
   The page also has separate initial and post-operation fetch paths that can 
overlap. A slower, older response can therefore overwrite a newer snapshot. In 
mock mode, `updateClusterConfig()` does not update the mock store, so any later 
read restores the pre-save configuration.
   
   ### Reproduction
   
   1. Open `/cluster` with auto-refresh enabled.
   2. Observe a Broker TPS or Proxy connection value from the `listClusters()` 
response.
   3. Wait two seconds without changing the backend response.
   
   The displayed value changes locally even though no new Cluster API request 
was made. The same timer can race the Proxy detail test (for example, expected 
`1,842` but a random value is rendered).
   
   ### Expected behavior
   
   - Metrics and topology come only from the latest successful `listClusters()` 
response.
   - Mounting refreshes immediately. While enabled, the next refresh is 
scheduled two seconds after the previous request completes, so requests never 
overlap.
   - Turning polling off cancels the next run; turning it back on refreshes 
immediately.
   - Initial, manual, and post-operation refreshes share the same coordinator. 
An operation requested during an older in-flight GET must receive a serialized 
follow-up GET.
   - An empty response clears the table and metric maps.
   - A background failure preserves the last successful snapshot, shows a red 
refresh status, avoids repeated toasts, and keeps retrying. Initial/manual 
failures remain visible to the user.
   - Unmounting prevents late responses from updating state or scheduling more 
work.
   - Mock configuration updates persist in the mock store.
   
   ### Root cause
   
   `web/src/pages/cluster/index.tsx` implements auto-refresh with a local 
`setInterval` and random perturbation rather than polling the existing Cluster 
service. Initial and operation refreshes use separate asynchronous functions. 
`web/src/services/clusterService.ts` returns early for mock configuration 
updates without mutating `clusters`.
   
   ### Scope
   
   - Replace the synthetic timer with non-overlapping recursive polling of the 
existing `listClusters()` service.
   - Coordinate foreground/background refresh triggers and expose manual 
refresh plus success/failure status.
   - Fix mock `updateClusterConfig()` persistence.
   - Add deterministic fake-timer/deferred-promise page tests and mock service 
persistence tests.
   - Do not introduce a new Metrics subsystem.
   
   Conceptually related [PR 
#657](https://github.com/apache/rocketmq-dashboard/pull/657) currently changes 
only server-side trace model files and does not modify the Cluster page, 
Cluster API, polling, or frontend tests. This fix intentionally remains a 
focused consumer of the existing Cluster API.
   
   I am working on this focused fix and will submit a PR against 
`rocketmq-studio`.
   


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