fix(pubsub): prevent double reconnect in releaseConn (#3833)

When a connection is both not usable and has a bad conn error,
releaseConn would call reconnect twice — first establishing a new
connection, then immediately closing it to create another. Add early
return after the first reconnect to avoid the wasted connection.
This commit is contained in:
cxljs
2026-05-29 12:42:20 +03:00
committed by GitHub
parent 7d05dd3b7c
commit 65d6abde0d
+1
View File
@@ -173,6 +173,7 @@ func (c *PubSub) releaseConn(ctx context.Context, cn *pool.Conn, err error, allo
if !cn.IsUsable() || cn.ShouldHandoff() {
c.reconnect(ctx, fmt.Errorf("pubsub: connection is not usable"))
return
}
if isBadConn(err, allowTimeout, c.opt.Addr) {