-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: handle context errors returned by service handler #5156
Conversation
test/server_test.go
Outdated
defer cancel() | ||
_, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}) | ||
if s, ok := status.FromError(err); !ok || s.Code() != codes.DeadlineExceeded { | ||
t.Fatalf("ss.Client.EmptyCall(ctx, _) = _, %v; want _, <status with Code()=DeadlineExceeded>", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid underscores in these error message. They make them really hard to read and add no value. I know this is the way many existing tests report errors, but do we need to continue doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting deleting _,
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add no value
I have to disagree on this a bit. They show the parameter/return signature of the function being called accurately. If a function accepts 3 values and returns 3, but you only show 1 or 2 of each of them, how do you know what the values represent?
If you want to remove them here then don't imply the function only returns one value. Do something like this instead:
t.Fatalf("ss.Client.EmptyCall() got error %v; want status with Code()=DeadlineExceeded", err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the docstrings here:
Lines 48 to 52 in 14c1138
// StreamHandler defines the handler called by gRPC server to complete the | |
// execution of a streaming RPC. If a StreamHandler returns an error, it | |
// should be produced by the status package, or else gRPC will use | |
// codes.Unknown as the status code and err.Error() as the status message | |
// of the RPC. |
and here:
Lines 74 to 77 in 14c1138
// UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal | |
// execution of a unary RPC. If a UnaryHandler returns an error, it should be produced by the | |
// status package, or else gRPC will use codes.Unknown as the status code and err.Error() as | |
// the status message of the RPC. |
Done |
…service handler RELEASE NOTES: * server: convert context errors returned by service handlers to status with the correct status code, instead of Unknown
3bfe570
to
5b01c4c
Compare
fixes #5155
RELEASE NOTES:
Canceled
orDeadlineExceeded
), instead ofUnknown