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 f9ea3a52b fix(message): tell an empty queue load apart from a load
that never ran (#6939)
f9ea3a52b is described below
commit f9ea3a52b4c7ec494e2e3c5269ebc4b219ab282c
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:22:56 2026 +0800
fix(message): tell an empty queue load apart from a load that never ran
(#6939)
---
web/src/components/QueueBrowser.tsx | 25 ++++++++++++++++-
web/src/components/__tests__/QueueBrowser.test.tsx | 31 ++++++++++++++++++++++
web/src/i18n/translations.ts | 4 +++
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/web/src/components/QueueBrowser.tsx
b/web/src/components/QueueBrowser.tsx
index 87deed2ab..fec3509f8 100644
--- a/web/src/components/QueueBrowser.tsx
+++ b/web/src/components/QueueBrowser.tsx
@@ -59,6 +59,10 @@ export const useQueueBrowser = (instanceId?: string) => {
const [offsets, setOffsets] = useState<Record<string, number>>({});
const [pulling, setPulling] = useState<Set<string>>(() => new Set());
const [entries, setEntries] = useState<PulledEntry[]>([]);
+ // A load that ran and found nothing is not the same as a load that never
ran, and a failed
+ // load is neither: the results panel needs the three states separately.
+ const [hasLoaded, setHasLoaded] = useState(false);
+ const [loadFailed, setLoadFailed] = useState(false);
const requestSeqRef = useRef(0);
const loadingRef = useRef(false);
const pullingRef = useRef(new Map<string, symbol>());
@@ -74,6 +78,8 @@ export const useQueueBrowser = (instanceId?: string) => {
setLoading(false);
pullingRef.current.clear();
setPulling(new Set());
+ setHasLoaded(false);
+ setLoadFailed(false);
});
return () => {
// Leaving the page invalidates pending loads and pulls just like a
scope change.
@@ -86,6 +92,7 @@ export const useQueueBrowser = (instanceId?: string) => {
loadingRef.current = true;
const requestId = ++requestSeqRef.current;
setLoading(true);
+ setLoadFailed(false);
setQueues([]);
setOffsets({});
setEntries([]);
@@ -97,6 +104,7 @@ export const useQueueBrowser = (instanceId?: string) => {
const result = await getQueueOffsets({ instanceId, topic });
if (requestId !== requestSeqRef.current) return;
setQueues(result);
+ setHasLoaded(true);
const initial: Record<string, number> = {};
for (const q of result) {
initial[`${q.brokerName}-${q.queueId}`] =
@@ -105,6 +113,7 @@ export const useQueueBrowser = (instanceId?: string) => {
setOffsets(initial);
} catch (err) {
if (requestId === requestSeqRef.current) {
+ setLoadFailed(true);
message.error(err instanceof Error ? err.message :
t('queueBrowser.loadQueuesFailed'));
}
} finally {
@@ -166,6 +175,8 @@ export const useQueueBrowser = (instanceId?: string) => {
setOffsets,
pulling,
entries,
+ hasLoaded,
+ loadFailed,
loadQueues,
handlePull,
closeEntry,
@@ -411,10 +422,22 @@ export const QueueBrowserResults = ({ state,
onOpenMessage }: QueueBrowserResult
<Flex justify="center" style={{ padding: 32 }}>
<Spin />
</Flex>
+ ) : state.loadFailed ? (
+ <Empty
+ image={Empty.PRESENTED_IMAGE_SIMPLE}
+ description={t('queueBrowser.loadQueuesFailed')}
+ style={{ padding: '32px 0' }}
+ >
+ <Button size="small" onClick={() => void state.loadQueues()}>
+ {t('common.retry')}
+ </Button>
+ </Empty>
) : state.queues.length === 0 ? (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
- description={t('queueBrowser.emptyHint')}
+ description={t(
+ state.hasLoaded ? 'queueBrowser.noReadableQueues' :
'queueBrowser.emptyHint',
+ )}
style={{ padding: '32px 0' }}
/>
) : (
diff --git a/web/src/components/__tests__/QueueBrowser.test.tsx
b/web/src/components/__tests__/QueueBrowser.test.tsx
index cec5dab3e..9dbea5eb3 100644
--- a/web/src/components/__tests__/QueueBrowser.test.tsx
+++ b/web/src/components/__tests__/QueueBrowser.test.tsx
@@ -503,6 +503,37 @@ describe('QueueBrowser request ownership', () => {
expect(screen.queryByRole('region', { name: '消息属性'
})).not.toBeInTheDocument();
expect(screen.queryByText('queue-trace-123')).not.toBeInTheDocument();
});
+
+ it('does not ask the operator to load queues that were loaded and came back
empty', async () => {
+ vi.mocked(getQueueOffsets).mockResolvedValue([]);
+ const user = userEvent.setup();
+ render(<QueueBrowserResultsProbe />);
+
+ await user.click(screen.getByRole('button', { name: 'topic-a' }));
+ await user.click(screen.getByRole('button', { name: 'load' }));
+
+ // The load ran and the topic answered with no readable queues: the panel
must not keep asking
+ // for the step the operator just performed.
+ expect(await screen.findByText(/没有可读队列/)).toBeInTheDocument();
+ expect(
+ screen.queryByText('选择 Topic 并点击「加载队列」,按队列浏览消息'),
+ ).not.toBeInTheDocument();
+ });
+
+ it('keeps a failed queue load visible and retryable instead of the pre-load
hint', async () => {
+ vi.mocked(getQueueOffsets).mockRejectedValue(new Error('nameserver
unreachable'));
+ const user = userEvent.setup();
+ render(<QueueBrowserResultsProbe />);
+
+ await user.click(screen.getByRole('button', { name: 'topic-a' }));
+ await user.click(screen.getByRole('button', { name: 'load' }));
+
+ expect(await screen.findByText('加载队列信息失败')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /重\s*试/ })).toBeInTheDocument();
+ expect(
+ screen.queryByText('选择 Topic 并点击「加载队列」,按队列浏览消息'),
+ ).not.toBeInTheDocument();
+ });
});
describe('QueueBrowser localization', () => {
diff --git a/web/src/i18n/translations.ts b/web/src/i18n/translations.ts
index c75821043..b78bec39f 100644
--- a/web/src/i18n/translations.ts
+++ b/web/src/i18n/translations.ts
@@ -896,6 +896,10 @@ const translations: Record<string, Record<Lang, string>> =
{
zh: '选择 Topic 并点击「加载队列」,按队列浏览消息',
en: 'Select a topic and click "Load Queues" to browse messages by queue',
},
+ 'queueBrowser.noReadableQueues': {
+ zh: '该 Topic 没有可读队列(只写权限,或读队列数为 0)',
+ en: 'This topic exposes no readable queues (a write-only permission, or
zero read queues)',
+ },
'queueBrowser.offsetRange': { zh: 'Offset 范围', en: 'Offset Range' },
'queueBrowser.queueSummary': {
zh: '共 {queues} 个队列,总消息量 {messages} 条',