Skip to content

Commit

Permalink
Merge pull request #132 from iamqizhao/err-fix
Browse files Browse the repository at this point in the history
fix a malformed error status
  • Loading branch information
iamqizhao committed Mar 23, 2015
2 parents 03b4c62 + 591c117 commit fd70cd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion call.go
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions test/end2end_test.go
Expand Up @@ -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()
Expand Down

0 comments on commit fd70cd3

Please sign in to comment.