From 2d031d25423ad4ea54b616a843d2d47686ce7e4e 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..3a70f46b 100644 --- a/gateway/gateway_impl.go +++ b/gateway/gateway_impl.go @@ -146,6 +146,9 @@ func (g *gatewayImpl) open(ctx context.Context) error { g.Close(closeCtx) return ctx.Err() case err = <-readyChan: + closeCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + g.Close(closeCtx) if err != nil { return fmt.Errorf("failed to open gateway connection: %w", err) }