Skip to content
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

Closed
mustafasen81 opened this issue Dec 11, 2023 · 4 comments · Fixed by #6891
Closed
Assignees

Comments

@mustafasen81
Copy link
Contributor

mustafasen81 commented Dec 11, 2023

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".

@easwars
Copy link
Contributor

easwars commented Dec 15, 2023

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 grpc.Status for methods on the server side. But the API is what it is, and changing that would be a big breaking change.

The status code and message returned to the client is what you can reliably use to understand more about the status of the RPC.

@dfawley
Copy link
Member

dfawley commented Dec 17, 2023

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.

Copy link

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.

@github-actions github-actions bot added the stale label Dec 23, 2023
@mustafasen81
Copy link
Contributor Author

Created a PR as a proposed fix. #6891

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants