diff --git a/call.go b/call.go index 13c8b821..32ca7eb3 100644 --- a/call.go +++ b/call.go @@ -147,7 +147,7 @@ func Invoke(ctx context.Context, method string, args, reply proto.Message, cc *C // This was a retry; return the error from the last attempt. return toRPCErr(lastErr) } - return Errorf(codes.Internal, "%v", err) + return toRPCErr(err) } stream, err = sendRPC(ctx, callHdr, t, args, topts) if err != nil { diff --git a/test/end2end_test.go b/test/end2end_test.go index 504e7f6f..4b3c1db6 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -301,6 +301,18 @@ func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, tc testpb.TestService return } +func TestTimeoutOnDeadServer(t *testing.T) { + s, tc := setUp(false, math.MaxUint32) + s.Stop() + // Set -1 as the timeout to make sure if transportMonitor gets error + // notification in time the failure path of the 1st invoke of + // ClientConn.wait hits the deadline exceeded error. + ctx, _ := context.WithTimeout(context.Background(), -1) + if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); grpc.Code(err) != codes.DeadlineExceeded { + t.Fatalf("TestService/EmptyCall(%v, _) = _, error %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded) + } +} + func TestEmptyUnary(t *testing.T) { s, tc := setUp(true, math.MaxUint32) defer s.Stop()