Skip to content

Commit 73d70c0

Browse files
committed
address feedback
1 parent e1e332b commit 73d70c0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pkg/loop/internal/net/client.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ func (c *clientConn) Invoke(ctx context.Context, method string, args any, reply
8989
// connect in order to not block the caller indefinitely.
9090
// If for whatever reason the LOOPP is down the caller should retry whatever
9191
// call they were making.
92-
c.Logger.Warnw("clientConn: Invoke: context canceled, stopping refresh",
92+
c.Logger.Warnw("clientConn: Invoke: context done, stopping refresh",
9393
"method", method,
9494
"err", err,
9595
"ctxErr", ctx.Err())
96-
// TODO: also return ctx.Err()?
97-
return err
96+
return ctx.Err()
9897
}
9998
if method == pb.Service_Close_FullMethodName {
10099
// don't reconnect just to call Close
@@ -128,12 +127,11 @@ func (c *clientConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, metho
128127
// connect in order to not block the caller indefinitely.
129128
// If for whatever reason the LOOPP is down the caller should retry whatever
130129
// call they were making.
131-
c.Logger.Warnw("clientConn: NewStream: context canceled, stopping refresh",
130+
c.Logger.Warnw("clientConn: NewStream: context done, stopping refresh",
132131
"method", method,
133132
"err", err,
134133
"ctxErr", ctx.Err())
135-
// TODO: also return ctx.Err()?
136-
return s, err
134+
return s, ctx.Err()
137135
}
138136
c.Logger.Errorw("clientConn: NewStream: terminal error, refreshing connection", "err", err)
139137
cc, refErr = c.refresh(ctx, cc)

pkg/loop/internal/net/client_lifecycle_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ func TestClient_Lifecycle(t *testing.T) {
9090

9191
// This call should return Canceled immediately and NOT trigger refresh.
9292
err = setup.Invoke(ctxCancelled, "/Service/Foo", nil, nil)
93-
94-
require.Equal(t, codes.Canceled, status.Code(err))
93+
require.ErrorIs(t, err, context.Canceled)
9594

9695
// If the bug exists, newClientFn will be called AGAIN (incrementing to 2).
9796
// If fixed, it should remain 1.
@@ -136,7 +135,7 @@ func TestClient_Lifecycle(t *testing.T) {
136135
stream, err := setup.NewStream(ctxCancelled, &grpc.StreamDesc{StreamName: "Foo", ClientStreams: true, ServerStreams: true}, "/Service/Foo")
137136

138137
require.Error(t, err)
139-
require.Equal(t, codes.Canceled, status.Code(err))
138+
require.ErrorIs(t, err, context.Canceled)
140139
require.Nil(t, stream)
141140

142141
require.Equal(t, 1, setup.newClientCalls, "Should NOT refresh connection on NewStream context cancellation")

0 commit comments

Comments
 (0)