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 df0db03bf fix(web): keep failing auto-refresh ticks from toasting on 
every interval (#5285)
df0db03bf is described below

commit df0db03bf5590bf7a9486016da99ac1fbea9d1c6
Author: Apulupie <[email protected]>
AuthorDate: Fri Oct 9 19:31:13 2026 +0800

    fix(web): keep failing auto-refresh ticks from toasting on every interval 
(#5285)
    
    The consumer page's 2-second background refresh shares 
`loadConsumerGroupPage` with user-initiated
    loads, and its catch branch checked only the request id - not whether the 
load was silent. With the
    backend down, every tick raised the same error toast, turning one transient 
outage into an unbounded
    stack of toasts. The guard is now `requestId === groupRequestIdRef.current 
&& !silent`, matching the
    three other silent paths on the page; user-initiated failures still surface.
    
    `ConsumerPage.test.tsx` 46 tests green (including the four import-toast 
cases added today in #5238 and
    the spinner case from #5121), prettier clean. Mutation-checked: removing 
`&& !silent` makes the new
    case fail with the toast fired three times.
    
    Maintainer edit on top of the contribution: dropped the `aria-label="自动刷新"` 
the branch had added to
    the refresh button and selected it in the test by role and accessible-name 
pattern instead, so the
    button keeps one source of truth for its label.
---
 .../pages/instance/__tests__/ConsumerPage.test.tsx | 22 +++++++++++++++++++++-
 web/src/pages/instance/consumer.tsx                |  7 ++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/web/src/pages/instance/__tests__/ConsumerPage.test.tsx 
b/web/src/pages/instance/__tests__/ConsumerPage.test.tsx
index 859bb90f8..95632fe86 100644
--- a/web/src/pages/instance/__tests__/ConsumerPage.test.tsx
+++ b/web/src/pages/instance/__tests__/ConsumerPage.test.tsx
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-import { App, Modal } from 'antd';
+import { App, Modal, message } from 'antd';
 import { act, cleanup, fireEvent, render, screen, waitFor, within } from 
'@testing-library/react';
 import userEvent from '@testing-library/user-event';
 import type React from 'react';
@@ -339,6 +339,26 @@ describe('Consumer page', () => {
     expect(screen.queryByRole('button', { name: /删除 \(1\)$/ 
})).not.toBeInTheDocument();
   });
 
+  it('stays silent when background auto-refresh ticks fail', async () => {
+    const user = userEvent.setup({ pointerEventsCheck: 0 });
+    vi.mocked(consumerService.listConsumerGroupPage)
+      .mockResolvedValueOnce(groupPage([group]))
+      .mockRejectedValue(new Error('backend down'));
+    const errorSpy = vi.spyOn(message, 'error').mockImplementation((() => 
undefined) as never);
+    renderWithProviders(<ConsumerPage />);
+
+    expect(await screen.findByText('remote-cg')).toBeInTheDocument();
+    await user.click(screen.getByRole('button', { name: /自动刷新/ }));
+
+    // Enabling auto refresh fires one immediate silent reload plus the 2s 
interval ticks; the
+    // failed ticks must stay quiet instead of toasting on every tick.
+    await waitFor(() => 
expect(consumerService.listConsumerGroupPage).toHaveBeenCalledTimes(4), {
+      timeout: 7000,
+    });
+    expect(errorSpy).not.toHaveBeenCalled();
+    errorSpy.mockRestore();
+  });
+
   afterEach(async () => {
     await act(async () => {
       cleanup();
diff --git a/web/src/pages/instance/consumer.tsx 
b/web/src/pages/instance/consumer.tsx
index dd5624c4e..fffe1d524 100644
--- a/web/src/pages/instance/consumer.tsx
+++ b/web/src/pages/instance/consumer.tsx
@@ -343,7 +343,12 @@ const ConsumerPageContent = ({
         }
         return requestId === groupRequestIdRef.current ? result : undefined;
       } catch {
-        if (requestId === groupRequestIdRef.current) 
message.error(t('consumer.fetchListFailed'));
+        // A silent (auto-refresh) tick that fails must stay quiet: a toast 
every 2s while the
+        // backend is down turns one transient outage into an unbounded error 
storm. Only
+        // user-initiated loads surface the toast.
+        if (requestId === groupRequestIdRef.current && !silent) {
+          message.error(t('consumer.fetchListFailed'));
+        }
         return undefined;
       } finally {
         if (requestId === groupRequestIdRef.current) setLoading(false);

Reply via email to