This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new 49f9a4b25 fix(web): show an unresolvable topic consumer lag as 
unavailable (#4822)
49f9a4b25 is described below

commit 49f9a4b25e4693c1b425d5c06d1a0c286e0147fd
Author: Wang1rrr <[email protected]>
AuthorDate: Thu Oct 1 17:54:17 2026 +0800

    fix(web): show an unresolvable topic consumer lag as unavailable (#4822)
    
    The topic detail consumer list only treated metricsAvailable === false as
    "no number". The backend has a second way of saying that: when the broker
    returns ConsumeStats but a queue offset cannot be resolved,
    RocketMQMetadataProvider sets diffTotal to ConsumerLagResolver.UNKNOWN (-1)
    and leaves metricsAvailable true, because stats really were returned.
    
    That row rendered as a backlog of -1, which reads as a negative lag. The
    consumer page's queue column already routes the same field through
    isLagAvailable and prints the unavailable label, so the two pages disagreed
    about the same sentinel. Reuse that guard here.
---
 .../pages/instance/__tests__/TopicPage.test.tsx    | 27 ++++++++++++++++++++++
 web/src/pages/instance/topic.tsx                   |  3 ++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/web/src/pages/instance/__tests__/TopicPage.test.tsx 
b/web/src/pages/instance/__tests__/TopicPage.test.tsx
index ee38da960..31f7f4196 100644
--- a/web/src/pages/instance/__tests__/TopicPage.test.tsx
+++ b/web/src/pages/instance/__tests__/TopicPage.test.tsx
@@ -1158,6 +1158,33 @@ describe('TopicPage', () => {
     expect(await screen.findAllByText('不可用')).not.toHaveLength(0);
   });
 
+  it('renders an unresolvable Topic consumer lag as unavailable instead of 
-1', async () => {
+    const user = userEvent.setup();
+    mockTopicsList([buildTopics(1)[0]]);
+    topicServiceMocks.getTopicConsumerPage.mockResolvedValue({
+      items: [
+        {
+          group: 'cg-orders',
+          consumeType: 'CLUSTERING',
+          messageModel: 'CLUSTERING',
+          consumeTps: 5,
+          // ConsumerLagResolver.UNKNOWN: the broker answered, but this 
group's lag is not
+          // resolvable, and metricsAvailable stays true because stats were 
returned.
+          diffTotal: -1,
+        },
+      ],
+      total: 1,
+      page: 1,
+      pageSize: 20,
+    });
+    renderWithProviders();
+
+    await user.click(await screen.findByRole('button', { name: /详情/ }));
+
+    expect(await screen.findAllByText('不可用')).not.toHaveLength(0);
+    expect(screen.queryByText('-1')).toBeNull();
+  });
+
   it('renders the broadcasting consumer model from the API value with the 
broadcast color', async () => {
     const user = userEvent.setup();
     mockTopicsList([buildTopics(1)[0]]);
diff --git a/web/src/pages/instance/topic.tsx b/web/src/pages/instance/topic.tsx
index ea6006e5e..44ad158f1 100644
--- a/web/src/pages/instance/topic.tsx
+++ b/web/src/pages/instance/topic.tsx
@@ -87,6 +87,7 @@ import {
   validateTopicCsvImport,
   type ResourceImportRow,
 } from '../../utils/resourceCsvImport';
+import { isLagAvailable } from '../../utils/consumerLag';
 import { downloadCsv } from '../../utils/download';
 import { formatDateTime, formatNumber } from '../../utils/format';
 import { tableScrollX } from '../../utils/table';
@@ -976,7 +977,7 @@ const TopicPageContent = ({
       dataIndex: 'diffTotal',
       key: 'diffTotal',
       render: (n: number, record) =>
-        record.metricsAvailable === false ? (
+        record.metricsAvailable === false || !isLagAvailable(n) ? (
           <Text type="secondary">不可用</Text>
         ) : (
           <Text type={n > 100 ? 'warning' : undefined}>{formatNumber(n)}</Text>

Reply via email to