This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new cef1ce5cb fix(topic): verify routes before reporting broker recovery
(#6890)
cef1ce5cb is described below
commit cef1ce5cb47d919a37d0a38499610d33da22500d
Author: coder999o <[email protected]>
AuthorDate: Thu Nov 26 19:51:47 2026 -0800
fix(topic): verify routes before reporting broker recovery (#6890)
---
.../pages/instance/__tests__/TopicPage.test.tsx | 55 ++++++++++++++++++++++
web/src/pages/instance/topic.tsx | 6 +++
2 files changed, 61 insertions(+)
diff --git a/web/src/pages/instance/__tests__/TopicPage.test.tsx
b/web/src/pages/instance/__tests__/TopicPage.test.tsx
index e1df78c5a..55b72b4ec 100644
--- a/web/src/pages/instance/__tests__/TopicPage.test.tsx
+++ b/web/src/pages/instance/__tests__/TopicPage.test.tsx
@@ -1675,6 +1675,61 @@ describe('TopicPage', () => {
expect(groupLink.closest('a')).not.toBeNull();
});
+ it.each([
+ {
+ action: 'rebuild',
+ openButton: /详情/,
+ actionName: /在 Broker 上重建/,
+ failure: '重建 Topic 失败,请检查 Broker 状态后重试',
+ success: 'Topic「topic-01」已在 Broker 上重建',
+ },
+ {
+ action: 'sync',
+ openButton: /同步/,
+ actionName: /同\s*步/,
+ failure: '同步 Topic「topic-01」失败,请检查 Broker 状态后重试',
+ success: 'Topic「topic-01」已同步到 Broker',
+ },
+ ])('keeps $action retryable until the route recheck returns a broker', async
(scenario) => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ mockTopicsList(buildTopics(1));
+ topicServiceMocks.getTopicRoutes
+ .mockReset()
+ .mockResolvedValueOnce([])
+ .mockResolvedValueOnce([])
+ .mockResolvedValueOnce([healthyBrokerRoute]);
+ renderWithProviders();
+
+ await screen.findByText('topic-01');
+ await user.click(screen.getByRole('button', { name: scenario.openButton
}));
+ const dialog = await screen.findByRole('dialog');
+ await user.click(await within(dialog).findByRole('button', { name:
scenario.actionName }));
+
+ expect(await screen.findByText(scenario.failure)).toBeInTheDocument();
+ expect(screen.queryByText(scenario.success)).not.toBeInTheDocument();
+ expect(within(dialog).queryByText('已同步')).not.toBeInTheDocument();
+ await waitFor(() =>
+ expect(within(dialog).getByRole('button', { name: scenario.actionName
})).toBeEnabled(),
+ );
+
+ await user.click(within(dialog).getByRole('button', { name:
scenario.actionName }));
+
+ expect(await screen.findByText(scenario.success)).toBeInTheDocument();
+ expect(topicServiceMocks.createTopic).toHaveBeenCalledTimes(2);
+ expect(topicServiceMocks.getTopicRoutes).toHaveBeenLastCalledWith(
+ 'topic-01',
+ 'instance-proxy-1',
+ );
+ if (scenario.action === 'sync') {
+ expect(within(dialog).getByText('已同步')).toBeInTheDocument();
+ expect(within(dialog).getByRole('button', { name: scenario.actionName
})).toBeDisabled();
+ } else {
+ expect(
+ within(dialog).queryByRole('button', { name: scenario.actionName }),
+ ).not.toBeInTheDocument();
+ }
+ });
+
it('keeps a reopened sync modal owned by its newest route check', async ()
=> {
const user = userEvent.setup({ pointerEventsCheck: 0 });
let resolveFirst!: (routes: BrokerRoute[]) => void;
diff --git a/web/src/pages/instance/topic.tsx b/web/src/pages/instance/topic.tsx
index c53e8640e..82c54e8ba 100644
--- a/web/src/pages/instance/topic.tsx
+++ b/web/src/pages/instance/topic.tsx
@@ -581,6 +581,9 @@ const TopicPageContent = ({
});
const routes = await getTopicRoutes(topic.name, instanceId);
setRoutesByTopic((previous) => ({ ...previous, [topic.name]: routes }));
+ if (routes.length === 0) {
+ throw new Error('Topic route is still missing after broker creation');
+ }
message.success(`Topic「${topic.name}」已在 Broker 上重建`);
} catch {
message.error('重建 Topic 失败,请检查 Broker 状态后重试');
@@ -679,6 +682,9 @@ const TopicPageContent = ({
});
const routes = await getTopicRoutes(topic.name, instanceId);
setRoutesByTopic((previous) => ({ ...previous, [topic.name]: routes }));
+ if (routes.length === 0) {
+ throw new Error('Topic route is still missing after broker creation');
+ }
setSyncedTopics((previous) => new Set(previous).add(topic.name));
message.success(`Topic「${topic.name}」已同步到 Broker`);
} catch {