apache / apache/rocketmq-dashboard

[Studio][Bug] Producer page keeps the previous topic's connections after switching topics

Open
#4,168 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.4k
Forks
683
Avg merge
2d 14h
Merged PRs (30d)
58

Description

## Problem

On the Producer page (Studio), switching the selected topic only resets the producer-group suggestions. The connection table and the readiness banner keep showing the previous topic's query results while the form already points at the new topic.

## Evidence

`web/src/pages/studio/Producer.tsx`:

- `handleInstanceChange` (lines 121-131) clears `connectionList`/`connectionSummary` — instance changes are handled.
- `handleTopicChange` (lines 162-166) clears only `producerGroups` and the group input — connection results survive a topic change.
- `handleExport` (lines 277-294) stamps every exported row with `topic: connection.topic ?? selectedTopic` (line 286), so exporting after a topic switch labels the previous topic's client connections with the newly selected topic.

Two regression tests fail on the unmodified base (`0a596661`):

1. `clears stale connection results when the topic changes` — after querying `order-events` successfully and then selecting `payment-events`, `within(container).queryByText('producer-1')` still finds the stale client row. Red output: `expected document not to contain element, found producer-1`.
2. `exports connections with the form topic after switching topics` — after the switch the export button is still enabled (with the stale rows cached), so a click exports the previous topic's connection stamped with `payment-events`.

## Impact

A user who queries topic A, switches the topic selector to B (the UI intentionally does not auto-query on selection change), and then exports or reads the table gets topic A's client inventory presented as if it belonged to topic B. The readiness banner (`producer.connectionReady`) likewise describes the old query while the form shows the new topic.

## Expected behavior

Changing the topic should invalidate the previous query's visible results the same way changing the instance does: clear `connectionList` and `connectionSummary` (and let the export button's existing `disabled={connectionList.length === 0}` guard take over until a new query is run).

## Related work

- #1593 (closed, fixed by PR #2200) covered invalidation when a *new query is submitted* and `handleInstanceChange` covers instance switches; the topic-change path was never covered — `handleTopicChange` was introduced in commit c7c8e861 with only group-suggestion reset.
- #1285/#1286 scoped topics and results by *instance*; different dimension.
- #1041 (502 for non-existent topic) is unrelated.

## PR

Fix: #4169.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read web/src/pages/studio/Producer.tsx, comparing handleTopicChange with handleInstanceChange and checking handleExport. Run the two regression tests named in the issue. Done means changing topics removes the previous connection results and readiness state, and export remains disabled until a new query is run.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.