From 29186feccc8af52cb93a9e6ab8d6d09f3395d9a1 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Tue, 9 Jun 2026 14:07:05 +0000 Subject: [PATCH] Fix ordering in cleanup function --- internal/restrictednet/https.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/restrictednet/https.go b/internal/restrictednet/https.go index 08ae7350..ea08c6c8 100644 --- a/internal/restrictednet/https.go +++ b/internal/restrictednet/https.go @@ -45,16 +45,16 @@ func (c *Client) OpenHTTPS(ctx context.Context, destinationTLSName string, desti cleanup = func() error { var errs []error httpClient.CloseIdleConnections() + err = connection.Close() + if err != nil && !errors.Is(err, net.ErrClosed) { + errs = append(errs, fmt.Errorf("closing connection: %w", err)) + } const remove = true err := c.firewall.AcceptOutputFromIPPortToIPPort(context.Background(), "tcp", c.outboundInterface, sourceAddrPort, destinationAddrPort, remove) if err != nil { errs = append(errs, fmt.Errorf("removing output traffic rule: %w", err)) } - err = connection.Close() - if err != nil && !errors.Is(err, net.ErrClosed) { - errs = append(errs, fmt.Errorf("closing connection: %w", err)) - } if len(errs) > 0 { return errors.Join(errs...) }