unbridled-41 opened a new pull request, #4166:
URL: https://github.com/apache/rocketmq-dashboard/pull/4166

   Fixes #4165.
   
   ## Problem / Evidence
   
   On the Cluster page (Broker 管理), the broker config preview panel renders 
whichever `previewClusterConfig` response arrives last. `handleConfigPreview` 
(`web/src/pages/cluster/index.tsx`, base `0a596661`, lines 648-669) awaits the 
request and then unconditionally commits the result — no request-generation 
guard — while every comparable async path in the same file 
(`nsConfigDiffRequestRef`, `brokerConfigDiffRequestRef`, 
`connectionTestRequestRef`, registry lists) is guarded.
   
   Reproduction: open 配置 for a broker → change a value → 预览 (response A slow) → 
Cancel → reopen 配置 → change values → 预览 (response B arrives) → slow response A 
resolves last → the panel shows A's diff while the form holds different values, 
and A's success toast fires while B's loading state is left stuck.
   
   A new regression test (`discards a superseded broker config preview 
response`) fails on the unmodified base: after the stale response resolves, 
`getByText('defaultTopicQueueNums=24')` fails because the panel was overwritten 
with the stale preview's `defaultTopicQueueNums=16`.
   
   ## Root cause / Fix
   
   Root cause: the preview async handler lacks the request-generation guard 
used by its sibling flows.
   
   Fix: add `configPreviewRequestRef`; bump it at the start of 
`handleConfigPreview`, and only commit state/toast/loading when the generation 
is still current. Invalidate the generation when the config dialog opens 
(`handleConfigOpen`), when it closes (`onCancel`), and when a form value 
changes (`onValuesChange`, which already cleared the panel). Mirrors the twin 
guard pattern from the #3292 fix.
   
   ## Priority & scoring
   
   - Impact 30/40 (misleading safety-check panel before a cluster-wide broker 
config apply) + breadth 13/20 (single dialog, but the same file's identical 
races were each accepted as bugs) + reproducibility 18/20 (deterministic 
deferred-promise regression) + maintainability value 14/20 (completes the 
file's guard pattern) = **PRIORITY 75** ≥ 70.
   - Mechanical pattern port with a red→green regression → **FIX_CONFIDENCE 
95** ≥ 80.
   
   ## Tests
   
   - Red: `npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx -t 
"discards a superseded broker config preview response"` on base → `Tests 1 
failed | 25 skipped` (`Unable to find an element with the text: 
defaultTopicQueueNums=24` — stale preview overwrote the latest one).
   - Green: same command after the fix → `Tests 1 passed`.
   - Module suite: `npx vitest run 
src/pages/cluster/__tests__/ClusterPage.test.tsx` → `Test Files 1 passed (1)`, 
`Tests 26 passed (26)` (25 pre-existing + 1 new).
   - Full web suite: `npx vitest run` → 945 tests; first run `2 failed | 943 
passed` (AclPage ×1, ConsumerPage ×2 — none of these files is touched by this 
change); reruns of those two files in isolation with the fix applied → `Tests 
54 passed (54)`. This matches the documented load-flakiness of those files 
under full-suite parallelism (see verification comment for the base-branch 
stash check).
   - `npx tsc --noEmit` clean; `npx eslint` on both changed files clean; `npm 
run build` succeeds (`✓ built in 9.81s`).
   
   ## Risk
   
   Low. The change only adds a generation guard around an existing async 
handler and bumps the generation at three existing invalidation points; no API, 
data, or visual changes. The one behavioral difference is intended: responses 
from superseded preview requests no longer write state or toast. The submit 
path (`handleConfigSubmit`) is intentionally untouched — its result is guarded 
by `confirmLoading` and revalidates on the server.
   


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