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 73c415b5 fix(client.go): handle sync settings error during startup
(#1235)
73c415b5 is described below
commit 73c415b5d80ef290fed9a2bc194f24f6bd6ce6b0
Author: Quan <[email protected]>
AuthorDate: Wed Apr 29 13:50:32 2026 +0800
fix(client.go): handle sync settings error during startup (#1235)
When the client is not yet initialized and settings synchronization fails,
propagate the error to startUp() method so it can return immediately instead
of blocking forever waiting for settings. Also added startUpError field to
the client struct to store errors that occur during startup.
Change-Id: I5c28c65922b81083ac20f70aec2d4091248572c2
---
golang/client.go | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/golang/client.go b/golang/client.go
index 10854bda..7aa17635 100644
--- a/golang/client.go
+++ b/golang/client.go
@@ -117,6 +117,13 @@ func (cs *defaultClientSession) startUp() {
response, err := observer.Recv()
if err != nil {
+ // If the client has not yet initialized,
propagate the error to startUp() so it can
+ // return immediately instead of blocking
forever waiting for settings.
+ if !cs.cli.inited.Load() {
+ cs.cli.startUpError =
fmt.Errorf("failed to sync settings during startUp: %w", err)
+ cs.cli.log.Error(cs.cli.startUpError)
+ return
+ }
// we are recovering
if !cs.recovering {
cs.cli.log.Infof("Encountered error
while receiving TelemetryCommand, trying to recover, err=%v", err)
@@ -231,6 +238,7 @@ type defaultClient struct {
endpointsTelemetryClientsLock sync.RWMutex
on atomic.Bool
inited atomic.Bool
+ startUpError error
clientImpl isClient
ReceiveReconnect bool
notifyUnsubscribeLiteFunc func(*v2.NotifyUnsubscribeLiteCommand)
@@ -590,6 +598,9 @@ func (cli *defaultClient) startUp() error {
// wait syncSettings finish
for !cli.inited.Load() {
+ if cli.startUpError != nil {
+ return cli.startUpError
+ }
sugarBaseLogger.Infoln("wait for sync settings finish")
time.Sleep(time.Second)
}