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) } }