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 5cae84f64 fix(web): report a failed instance-list load on the two
remaining console pages (#6348)
5cae84f64 is described below
commit 5cae84f645df81725b842263b9f2c48a15db97fc
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:27:10 2026 +0800
fix(web): report a failed instance-list load on the two remaining console
pages (#6348)
---
web/src/pages/ops/__tests__/AlertsPage.test.tsx | 17 ++++++++++++
web/src/pages/ops/alerts.tsx | 31 +++++++++++++++++++---
web/src/pages/studio/BrokerCluster.tsx | 27 ++++++++++++++++---
.../pages/studio/__tests__/BrokerCluster.test.tsx | 14 ++++++++++
4 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/web/src/pages/ops/__tests__/AlertsPage.test.tsx
b/web/src/pages/ops/__tests__/AlertsPage.test.tsx
index b8b499b24..3dd4fc05f 100644
--- a/web/src/pages/ops/__tests__/AlertsPage.test.tsx
+++ b/web/src/pages/ops/__tests__/AlertsPage.test.tsx
@@ -259,6 +259,23 @@ describe('AlertsPage', () => {
expect(screen.queryByText('UNAVAILABLE 0null')).not.toBeInTheDocument();
});
+ it('reports a failed instance load in the rule dialog and retries it', async
() => {
+ vi.mocked(listInstances).mockRejectedValueOnce(new Error('instance
discovery failed'));
+ const user = userEvent.setup();
+ renderPage();
+
+ await user.click(await screen.findByRole('button', { name: '新建规则' }));
+
+ expect(await screen.findByText('RocketMQ
实例加载失败,请稍后重试')).toBeInTheDocument();
+
+ await user.click(screen.getByRole('button', { name: '重试' }));
+
+ await waitFor(() => expect(listInstances).toHaveBeenCalledTimes(2));
+ await waitFor(() =>
+ expect(screen.queryByText('RocketMQ
实例加载失败,请稍后重试')).not.toBeInTheDocument(),
+ );
+ });
+
it('renders rule configuration labels in English', async () => {
localStorage.setItem(LANGUAGE_STORAGE_KEY, 'en');
const user = userEvent.setup();
diff --git a/web/src/pages/ops/alerts.tsx b/web/src/pages/ops/alerts.tsx
index 064be4ef5..165e47b6e 100644
--- a/web/src/pages/ops/alerts.tsx
+++ b/web/src/pages/ops/alerts.tsx
@@ -264,6 +264,8 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded =
false }: AlertsPageP
const [selectedInstanceId, setSelectedInstanceId] = useState<string>();
const [metricLoading, setMetricLoading] = useState(false);
const [instances, setInstances] = useState<Instance[]>([]);
+ const [instancesLoadFailed, setInstancesLoadFailed] = useState(false);
+ const [instancesReloadNonce, setInstancesReloadNonce] = useState(0);
const [transferringRules, setTransferringRules] = useState(false);
const metricRequestVersion = useRef(0);
const testRequestVersion = useRef(0);
@@ -472,9 +474,16 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded
= false }: AlertsPageP
useEffect(() => {
void listInstances()
- .then(setInstances)
- .catch(() => message.error(t('alerts.instanceLoadFailed')));
- }, []);
+ .then((nextInstances) => {
+ setInstances(nextInstances);
+ setInstancesLoadFailed(false);
+ })
+ .catch(() => {
+ // A transient toast left the picker looking like a deployment without
instances once it
+ // faded: the failure is now state, and the retry re-runs this load.
+ setInstancesLoadFailed(true);
+ });
+ }, [instancesReloadNonce]);
const enabledCount = rules.filter((r) => r.enabled).length;
const selectedCount = selectedRuleIds.length;
@@ -1264,6 +1273,7 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded
= false }: AlertsPageP
>
<Select
placeholder={t('alerts.instanceRequired')}
+ status={instancesLoadFailed ? 'error' : undefined}
options={instances.map((instance) => ({
value: instance.name,
label: `${instance.name}${instance.vendor && instance.vendor
!== 'APACHE' ? ` (${instance.vendor})` : ''}`,
@@ -1275,6 +1285,21 @@ const AlertsPageContent = ({ domain = 'CLUSTER',
embedded = false }: AlertsPageP
}}
/>
</Form.Item>
+ {instancesLoadFailed && (
+ <Space size={4}>
+ <Typography.Text type="danger" style={{ fontSize: 14 }}>
+ {t('alerts.instanceLoadFailed')}
+ </Typography.Text>
+ <Button
+ type="link"
+ size="small"
+ style={{ padding: 0, height: 'auto' }}
+ onClick={() => setInstancesReloadNonce((nonce) => nonce + 1)}
+ >
+ {t('common.retry')}
+ </Button>
+ </Space>
+ )}
<Form.Item
name="metric"
diff --git a/web/src/pages/studio/BrokerCluster.tsx
b/web/src/pages/studio/BrokerCluster.tsx
index 91068da80..15c2db3d8 100644
--- a/web/src/pages/studio/BrokerCluster.tsx
+++ b/web/src/pages/studio/BrokerCluster.tsx
@@ -29,6 +29,7 @@ import {
App,
Select,
theme,
+ Typography,
} from 'antd';
import {
ArrowClockwise,
@@ -194,6 +195,8 @@ const BrokerClusterPage = () => {
const [nameServerData, setNameServerData] = useState<NameServerRecord[]>([]);
const [proxyData, setProxyData] = useState<ProxyRecord[]>([]);
const [instances, setInstances] = useState<Instance[]>([]);
+ const [instancesLoadFailed, setInstancesLoadFailed] = useState(false);
+ const [instancesReloadNonce, setInstancesReloadNonce] = useState(0);
const [selectedInstanceId, setSelectedInstanceId] = useState<string |
undefined>(undefined);
const mountedRef = useRef(true);
const loadRequestId = useRef(0);
@@ -245,6 +248,7 @@ const BrokerClusterPage = () => {
if (!active) return;
const apacheInstances = nextInstances.filter(supportsApacheRuntime);
setInstances(apacheInstances);
+ setInstancesLoadFailed(false);
setSelectedInstanceId((current) =>
apacheInstances.some((instance) => instance.name === current)
? current
@@ -252,14 +256,15 @@ const BrokerClusterPage = () => {
);
})
.catch(() => {
+ // A transient toast still left the page looking like a deployment
without instances, and
+ // clearing the loaded topology discarded data the failure says
nothing about.
if (!active) return;
- clearData();
- message.error(t('common.fetchDataFailed'));
+ setInstancesLoadFailed(true);
});
return () => {
active = false;
};
- }, [clearData, message, t]);
+ }, [instancesReloadNonce, t]);
useEffect(() => {
mountedRef.current = true;
@@ -539,9 +544,25 @@ const BrokerClusterPage = () => {
value={selectedInstanceId}
onChange={setSelectedInstanceId}
placeholder={t('common.selectInstance')}
+ status={instancesLoadFailed ? 'error' : undefined}
style={{ minWidth: 180 }}
options={instances.map((instance) => ({ value: instance.name,
label: instance.name }))}
/>
+ {instancesLoadFailed && (
+ <Space size={4}>
+ <Typography.Text type="danger" style={{ fontSize: 14 }}>
+ {t('instance.listLoadFailed')}
+ </Typography.Text>
+ <Button
+ type="link"
+ size="small"
+ style={{ padding: 0, height: 'auto' }}
+ onClick={() => setInstancesReloadNonce((nonce) => nonce + 1)}
+ >
+ {t('common.retry')}
+ </Button>
+ </Space>
+ )}
<Button
icon={<DownloadSimple size={14} />}
size="small"
diff --git a/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
b/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
index dacd9f18f..e03c7072b 100644
--- a/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
+++ b/web/src/pages/studio/__tests__/BrokerCluster.test.tsx
@@ -213,6 +213,20 @@ describe('BrokerCluster Page', () => {
expect(screen.queryByText('broker-api-a')).not.toBeInTheDocument();
});
+ it('reports a failed instance discovery with a retry that recovers the
topology', async () => {
+ vi.mocked(listInstances).mockRejectedValueOnce(new Error('instance
discovery failed'));
+ const user = userEvent.setup();
+ renderWithProviders(<BrokerCluster />);
+
+ expect(await screen.findByText('实例列表加载失败,请稍后重试')).toBeInTheDocument();
+
+ await user.click(screen.getByRole('button', { name: '重试' }));
+
+ await waitFor(() => expect(listInstances).toHaveBeenCalledTimes(2));
+ await screen.findAllByText('broker-api-a');
+ expect(screen.queryByText('实例列表加载失败,请稍后重试')).not.toBeInTheDocument();
+ });
+
it('should display broker status tags', async () => {
renderWithProviders(<BrokerCluster />);
await screen.findAllByText('broker-api-a');