/ go Public
net/http: HTTP/2 request context sometimes returns no error when the client disconnects #52183
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
What did you do?
Users sometimes abort file uploads before they finish, which propagates an error up the call stack. I try to see if the HTTP request was aborted by checking
request.Context().Err() != nil, in which case I ignore the error. Otherwise, I report it, so it can be investigated. (I am aware there might be rare cases when there is an unrelated error, after which the client disconnects, which will cause the error to be ignored, incorrectly.)
I created an example.
Here is also a self-signed certificate, for convenience.
I then try to start a rate-limited upload, and press Ctrl-C at random times before it completes.
What did you expect to see?
request.Context().Err()to always say
context canceled. Is this assumption correct?
What did you see instead?
In case of HTTP/1.1, it seems I always get the error
unexpected EOF, and
In case of HTTP/2, it seems the error is always
client disconnected, but most of the time
It seems there is some kind of race here. If I add a short sleep at the end of the handler, I get the expected context error.
I found what looks like the error that is returned, but it is unexported, so I cannot check it more directly.
The text was updated successfully, but these errors were encountered: