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 80f981aa8 fix(litetopic): report a failed session read instead of an 
empty drawer (#6117)
80f981aa8 is described below

commit 80f981aa8d4ce2ca4c5023058d822d0d7d1564b3
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:52:28 2026 +0800

    fix(litetopic): report a failed session read instead of an empty drawer 
(#6117)
---
 web/src/pages/studio/LiteTopic.tsx                | 23 +++++++++++++++++++++++
 web/src/pages/studio/__tests__/LiteTopic.test.tsx | 22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/web/src/pages/studio/LiteTopic.tsx 
b/web/src/pages/studio/LiteTopic.tsx
index bbdf47825..eb1476c02 100644
--- a/web/src/pages/studio/LiteTopic.tsx
+++ b/web/src/pages/studio/LiteTopic.tsx
@@ -167,6 +167,7 @@ const LiteTopicPage: React.FC = () => {
   const [sessionModalOpen, setSessionModalOpen] = useState(false);
   const [sessionData, setSessionData] = useState<LiteTopicSession | 
null>(null);
   const [sessionLoading, setSessionLoading] = useState(false);
+  const [sessionLoadFailed, setSessionLoadFailed] = useState(false);
   const [availableSessionIds, setAvailableSessionIds] = useState<string[]>([]);
   const [selectedSessionId, setSelectedSessionId] = useState<string>();
 
@@ -344,14 +345,17 @@ const LiteTopicPage: React.FC = () => {
     setSessionModalOpen(true);
     setSessionLoading(true);
     setSessionData(null);
+    setSessionLoadFailed(false);
     try {
       const data = await queryLiteTopicSession(sessionId);
       if (requestId !== sessionRequestId.current) return;
       setSessionData(data);
     } catch {
       if (requestId !== sessionRequestId.current) return;
+      // The drawer renders a missing detail as "no data", which a failed read 
cannot claim.
       message.error(t('liteTopic.fetchSessionFailed'));
       setSessionData(null);
+      setSessionLoadFailed(true);
     } finally {
       if (requestId === sessionRequestId.current) {
         setSessionLoading(false);
@@ -770,6 +774,25 @@ const LiteTopicPage: React.FC = () => {
     if (sessionLoading) {
       return <div style={{ textAlign: 'center', padding: 40 
}}>{t('common.loading')}...</div>;
     }
+    if (sessionLoadFailed) {
+      return (
+        <Alert
+          type="error"
+          showIcon
+          message={t('liteTopic.fetchSessionFailed')}
+          action={
+            <Button
+              size="small"
+              onClick={() => {
+                if (selectedSessionId) void 
handleViewSessions(selectedSessionId);
+              }}
+            >
+              {t('common.retry')}
+            </Button>
+          }
+        />
+      );
+    }
     if (!sessionData) {
       return <div style={{ textAlign: 'center', padding: 40 
}}>{t('common.noData')}</div>;
     }
diff --git a/web/src/pages/studio/__tests__/LiteTopic.test.tsx 
b/web/src/pages/studio/__tests__/LiteTopic.test.tsx
index eb840d496..cf43b6dd2 100644
--- a/web/src/pages/studio/__tests__/LiteTopic.test.tsx
+++ b/web/src/pages/studio/__tests__/LiteTopic.test.tsx
@@ -427,6 +427,28 @@ describe('LiteTopic Page', () => {
     expect(screen.queryByText('96%')).not.toBeInTheDocument();
   });
 
+  it('reports a failed session read instead of presenting the session as 
empty', async () => {
+    apiMocks.queryLiteTopicSession.mockRejectedValueOnce(new Error('offline'));
+    const user = userEvent.setup();
+    renderPage();
+
+    await screen.findByText('order-*');
+    await user.click(await screen.findByText('查看会话'));
+    const drawer = await screen.findByRole('dialog');
+
+    // The detail never arrived, so the drawer body must not fall back to "no 
data" for a session
+    // that is listed.
+    await waitFor(() => 
expect(apiMocks.queryLiteTopicSession).toHaveBeenCalledTimes(1));
+    expect(within(drawer).queryByText('暂无数据')).not.toBeInTheDocument();
+
+    await user.click(within(drawer).getByRole('button', { name: /重\s*试/ }));
+
+    await waitFor(() => 
expect(apiMocks.queryLiteTopicSession).toHaveBeenCalledTimes(2));
+    // The retry mock resolves the default session, so the drawer renders its 
detail instead of
+    // staying on the failure state.
+    expect(await within(drawer).findByText('session-1')).toBeInTheDocument();
+  });
+
   it('reports a consumed count that only covers part of the session', async () 
=> {
     // The consumed-offset scan reads at most MAX_SESSION_LITE_TOPIC_SCAN lite 
topics, so a session
     // with more of them only gets a lower bound. The drawer must not present 
it as a measured total

Reply via email to