Skip to content

Commit 64781a6

Browse files
ToreMerkelyclaude
andcommitted
fix(cloudrun): use errors.Join in Close() so both errors propagate (#4986)
Previous Close() returned only the first error if both client closes failed — the second was silently dropped: if sErr != nil { return sErr } return rErr errors.Join (Go 1.20+) preserves both, simpler, no behavior change when only one fails. Low-impact for a short-lived CLI but cheap to do right. Addresses two duplicate review comments on PR 833. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 41808e6 commit 64781a6

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

internal/cloudrun/cloudrun.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cloudrun
66

77
import (
88
"context"
9+
"errors"
910
"fmt"
1011
"strings"
1112
"time"
@@ -64,19 +65,14 @@ func New(ctx context.Context) (*Client, error) {
6465
}
6566

6667
// Close releases the underlying gRPC connections. Safe to call on a Client
67-
// constructed with a fake apiClient (returns nil). Returns the first error
68-
// from closing either client; the second is always attempted.
68+
// constructed with a fake apiClient (returns nil). Both clients are always
69+
// closed; errors from each are joined so neither is silently dropped.
6970
func (c *Client) Close() error {
7071
g, ok := c.api.(*gcpAPI)
7172
if !ok {
7273
return nil
7374
}
74-
sErr := g.services.Close()
75-
rErr := g.revisions.Close()
76-
if sErr != nil {
77-
return sErr
78-
}
79-
return rErr
75+
return errors.Join(g.services.Close(), g.revisions.Close())
8076
}
8177

8278
// ListServices returns every Cloud Run service in the given project+region,

0 commit comments

Comments
 (0)