From 64608397052b74fdae1a99dde6c00f1ee3ff6380 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 15 Feb 2020 11:35:08 +0000 Subject: [PATCH] when the stream errors cleanup the connection (#1199) --- grpc.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grpc.go b/grpc.go index e3ada84..272719c 100644 --- a/grpc.go +++ b/grpc.go @@ -218,6 +218,12 @@ func (g *grpcClient) stream(ctx context.Context, node *registry.Node, req client st, err := cc.NewStream(newCtx, desc, methodToGRPC(req.Service(), req.Endpoint()), grpcCallOptions...) if err != nil { + // we need to cleanup as we dialled and created a context + // cancel the context + cancel() + // close the connection + cc.Close() + // now return the error return nil, errors.InternalServerError("go.micro.client", fmt.Sprintf("Error creating stream: %v", err)) }