-
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
gRPC server stream returns status of Unknown when connection to the client closed #6845
Comments
gRPC status returned to your RPC handler on the server side is not a very reliable indicator of the actual error or status returned to the client. Ideally, it would have been nicer if we did not return a The status code and message returned to the client is what you can reliably use to understand more about the status of the RPC. |
All that said, I think changing the status code to be UNAVAILABLE if there is a lost connection -- which is what would be generated by the client if this kind of thing happens -- is not unreasonable, if you want to send a PR. |
This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
Created a PR as a proposed fix. #6891 |
If the underlying connection to the client is closed before sending the first message in a server stream, it gets a grpc error having the status of Unknown, as rpc error: code = Unknown desc = connection error: desc = "transport is closing". After an investigation, I found that if the connection is closed at the very beginning of the stream before the server writes the headers. When it writes the headers, it gets the ConnectionError and tries to convert it to a grpc status error by status.Convert(err).Err(). Since ConnectionError is not a grpc status error it converts the error to grpc status of Unknown.
Have a test reproducing the case: https://github.com/mustafasen81/grpc-status-unknown
What version of gRPC are you using?
v1.59.0
What version of Go are you using (
go version
)?1.21.4
What operating system (Linux, Windows, …) and version?
macOs Sonoma 14.0
What did you do?
If the underlying connection to the client is closed before sending the first message in a server stream, it gets a grpc error having the status of Unknown.
What did you expect to see?
rpc error: code = Unavailable desc = transport is closing
What did you see instead?
rpc error: code = Unknown desc = connection error: desc = "transport is closing".
The text was updated successfully, but these errors were encountered: