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

RongtongJin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a554b9c fix(nodejs): fail fast on NotFoundException during startup 
route fetch (#1374)
2a554b9c is described below

commit 2a554b9c408b27d0b71ed310c06804b8a8280dc6
Author: zhaohai <[email protected]>
AuthorDate: Wed Sep 23 10:20:53 2026 +0800

    fix(nodejs): fail fast on NotFoundException during startup route fetch 
(#1374)
    
    Non-not-found errors keep the 3-attempt retry with linear backoff, but
    NotFoundException (topic/consumer group does not exist) can never succeed
    on retry - surface it immediately so the error message and cause chain
    carry NotFoundException(40402) instead of a generic 'Failed to fetch
    topic routes after 3 attempts' wrapper.
---
 nodejs/src/client/BaseClient.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/nodejs/src/client/BaseClient.ts b/nodejs/src/client/BaseClient.ts
index acf694d5..6b6dfaa3 100644
--- a/nodejs/src/client/BaseClient.ts
+++ b/nodejs/src/client/BaseClient.ts
@@ -38,7 +38,7 @@ import {
 } from '../../proto/apache/rocketmq/v2/service_pb';
 import { createResource, getRequestDateTime, sign } from '../util';
 import { TopicRouteData, Endpoints } from '../route';
-import { ClientException, StatusChecker } from '../exception';
+import { ClientException, NotFoundException, StatusChecker } from 
'../exception';
 import { Settings } from './Settings';
 import { UserAgent } from './UserAgent';
 import { ILogger, getDefaultLogger } from './Logger';
@@ -170,6 +170,11 @@ export abstract class BaseClient {
         break;
       } catch (e) {
         lastError = e as Error;
+        // Not-found errors will never succeed on retry — fail fast, aligned
+        // with the Java client which surfaces NotFoundException immediately.
+        if (e instanceof NotFoundException) {
+          throw e;
+        }
         if (attempt < maxAttempts) {
           const backoffMs = 1000 * attempt; // Simple linear backoff: 1s, 2s, 
3s
           this.logger.warn('Fetch topic route failed during startup, will 
retry, clientId=%s, attempt=%d/%d, error=%s, backoff=%dms',

Reply via email to