From 80ccb7563e15ca57c438798f7ba27fb0f547628c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?To=CF=80?= Date: Wed, 4 Oct 2023 12:03:38 +0200 Subject: [PATCH] make sure gateway is closed on ready error --- gateway/gateway_impl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/gateway_impl.go b/gateway/gateway_impl.go index 4d1169d6..949034f2 100644 --- a/gateway/gateway_impl.go +++ b/gateway/gateway_impl.go @@ -147,6 +147,9 @@ func (g *gatewayImpl) open(ctx context.Context) error { return ctx.Err() case err = <-readyChan: if err != nil { + closeCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + g.Close(closeCtx) return fmt.Errorf("failed to open gateway connection: %w", err) } }