From e9007f7191972fd773f2c52ee207c7b62ea86e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Tue, 31 Mar 2026 16:49:41 +0200 Subject: [PATCH] [client] Fix connection swap to properly close old gRPC connection Close the old `gRPC.ClientConn` after successfully swapping to a new connection during reconnection. --- flow/client/client.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flow/client/client.go b/flow/client/client.go index 36f362f09..be142a2e9 100644 --- a/flow/client/client.go +++ b/flow/client/client.go @@ -154,21 +154,20 @@ func (c *GRPCClient) recreateConnection() error { return backoff.Permanent(ErrClientClosed) } - defer func(conn *grpc.ClientConn) { - _ = conn.Close() - }(c.clientConn) - conn, err := grpc.NewClient(c.clientConn.Target(), c.opts...) if err != nil { c.mu.Unlock() return fmt.Errorf("create new connection: %w", err) } + old := c.clientConn c.clientConn = conn c.realClient = proto.NewFlowServiceClient(conn) c.stream = nil c.mu.Unlock() + _ = old.Close() + return nil }