unbridled-41 opened a new issue, #4589:
URL: https://github.com/apache/rocketmq-dashboard/issues/4589
## Problem
On `/studio/broker-cluster` the instance discovery effect picks the first
Apache-capable instance and writes it into the selection on *every* run. The
effect lists the translation function `t` as a dependency and `t` is recreated
when the display language changes (`web/src/i18n/LangContext.tsx`), so
switching the language through the top-bar toggle re-runs the effect and
replaces the instance the operator picked with the first one — then the
topology below reloads for that other instance.
Steps to reproduce:
1. Open `/studio/broker-cluster` in a deployment with at least two Apache
instances.
2. Select the second instance in 选择实例 and wait for its
Broker/NameServer/Proxy data.
3. Switch the display language with the top-bar toggle.
4. The selector snaps back to the first instance and the tables show that
instance's topology.
## Studio Version
branch: master
git commit id: d50ffecc9d7e8f8f46da64198831bd7952e6974e
deployed as: built from source (frontend only)
## Evidence
- `web/src/pages/studio/BrokerCluster.tsx:236` —
`setSelectedInstanceId(apacheInstances[0]?.name)` runs unconditionally inside
an effect whose dependency list is `[clearData, message, t]` (`:246`).
- The twin page already guards exactly this write:
`web/src/pages/studio/Producer.tsx:104-108` keeps the current value when it is
still present in the loaded list (and its effect runs with mount-only
dependencies).
- Regression test
`web/src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx` selects
`instance-2`, switches the language through the real `LangProvider.setLang`,
and fails on `master`:
```
FAIL src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx >
BrokerCluster instance scope > keeps the instance the user selected when the
display language changes
AssertionError: expected last "vi.fn()" call to have been called with [
'instance-2' ]
- Expected
+ Received
[
- "instance-2",
+ "instance-1",
]
❯ src/pages/studio/__tests__/BrokerClusterInstanceScope.test.tsx:160:46
Test Files 1 failed (1)
Tests 1 failed (1)
```
## Impact
In a multi-instance deployment an operator reads another instance's broker,
nameserver and proxy topology while believing it is the instance they selected
— and the selector change is easy to miss when the language switch was the only
intended action.
## Expected behavior
Changing the display language re-renders text only. A selection that is
still present in the instance list must survive the re-run of the discovery
effect; only a stale selection (removed instance, or no selection yet) falls
back to the first Apache-capable instance.
## Related work
- In-repo guard for the same effect:
`web/src/pages/studio/Producer.tsx:104-108` (added with the producer
topic/instance scoping fixes).
- #2200 (merged) — same class of defect: an effect tied to the translation
function re-running and discarding user state.
## PR
Fix: #PR_PLACEHOLDER.
--
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]