-
Notifications
You must be signed in to change notification settings - Fork 108
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
Incorrect client disconnection error codes #645
Comments
Related issue: golang/go#52183 . Which seems to show |
FWIW, closing the actual connection is not the same as a cancellation with http/2. With http/2, the client aborts the stream, but the connection remains open. With http/1.1, since multiplexing a single connection is not supported, the only way a client can cancel is to disconnect. Though perhaps the server handler doesn't care about distinguishing the two cases -- in other words, maybe it doesn't care to distinguish the client intentionally cancelling a single stream vs. a network partition implicitly cancelling all streams (without the client's intent). |
Hi, just wanted to check in on the prioritization of this, particularly for the http2 case. |
@pqn, looks like @emcfarlane has opened a pull request, so hopefully it can be addressed in the next release. |
This PR wraps errors with the appropriate connect code of Cancelled or DeadlineExceeded if the context error is not nil. Improves error handling for some well known error cases that do not surface context.Cancelled errors. For example HTTP2 "client disconnect" string errors are now raised with a Cancelled code not an Unknown. This lets handlers check the error code for better handling and reporting of errors. Fix for #645
This should be addressed in v1.15.0 (resolved in #659). |
Describe the bug
On client disconnections for both HTTP1 and HTTP2 transports we should detect the client has disconnected and use an appropriate error code. Currently disconnects can see a
connect.CodeUknown
causing erroneous error reporting. To detect a client disconnect we could check the context for cancellation (see docs from deprecated http.CloseNotifier).To Reproduce
Create a connection and close the underlying net.Conn to replicate a dropped client connection:
Handler errors will be (only checked the envelope flow):
invalid_argument: protocol error: incomplete envelope: unexpected EOF
unknown: write envelope: io: read/write on closed pipe
invalid_argument: protocol error: incomplete envelope: client disconnected
unknown: write envelope: client disconnected
In all cases checking the context error will return a
context.Cancelled
error. The http2client disconnect
string is from this error.Environment (please complete the following information):
connect-go
version or commit:v0.1.12
go version
:go version go1.18.3 darwin/amd64
Additional context
Thanks to the reports from:
The text was updated successfully, but these errors were encountered: