diff --git a/internal/cli/cmd/cluster/grpcproxy.go b/internal/cli/cmd/cluster/grpcproxy.go index 6a2385cb1..49ce82108 100644 --- a/internal/cli/cmd/cluster/grpcproxy.go +++ b/internal/cli/cmd/cluster/grpcproxy.go @@ -60,12 +60,14 @@ func (g *grpcProxy) newBackendClient(ctx context.Context) (*grpc.ClientConn, err defer g.mu.Unlock() if g.backendClient != nil { - if g.backendClient.GetState() == connectivity.Ready { - fmt.Fprintf(console.Debug(ctx), "reused grpc connection\n") + connState := g.backendClient.GetState() + if connState == connectivity.Ready || connState == connectivity.Connecting { + fmt.Fprintf(console.Debug(ctx), "reused grpc connection: %v\n", connState) return g.backendClient, nil } - fmt.Fprintf(console.Debug(ctx), "cached grpc connection invalidated: %v\n", g.backendClient.GetState()) + closingErr := g.backendClient.Close() + fmt.Fprintf(console.Debug(ctx), "cached grpc connection invalidated: %v, closing err: %v\n", connState, closingErr) g.backendClient = nil }