-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/net/http2: Server.ReadTimeout does not fire for HTTP/2 requests #49837
Comments
/cc @aojea |
This seems to be the expected behavior, I can see that for ReadTimeout is the same as IdleTimeout for http2, and doesn't take the body into consideration
there is also a test that checks that the handler is not affected by the timeout https://github.com/golang/net/blob/d455829e376dcf0ca6aca82a86d093afbcc6a8ee/http2/server_test.go#L3891-L3917 It seems this comment from @bradfitz explains the decision ... anyway, if my understanding is wrong I'm happy to help if I have some guidance 😅 |
Thanks for finding the link to the previous discussion. IMO if this is the intended behaviour then the comment on
This isn't correct in the HTTP/2 context. At best, if the user has set |
CC @neild |
Rolling forward to 1.20. Please comment if you disagree. Thanks. |
Sorry for missing this when it was originally filed. So far as I can tell, |
Change https://go.dev/cl/446255 mentions this issue: |
Change https://go.dev/cl/446256 mentions this issue: |
Return an error when reading from the request body in a server handler after Server.ReadTimeout expires. Tested by net/http CL 446255. For golang/go#49837 Change-Id: Idcc3d92209f944bd7fead832525fd563b50bcebc Reviewed-on: https://go-review.googlesource.com/c/net/+/446256 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
We don't seem to have tests verifying that handler reads from the request body or writes to the response body time out properly. Add some. For #49837 For #56478 Change-Id: I0828edd6c86b071073fd1b22ccbb24f86114ab94 Reviewed-on: https://go-review.googlesource.com/c/go/+/446255 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/449935 mentions this issue: |
Fixed in golang.org/x/net v0.2.0, will be in go1.20. |
Return an error when reading from the request body in a server handler after Server.ReadTimeout expires. Tested by net/http CL 446255. For golang/go#49837 Change-Id: Idcc3d92209f944bd7fead832525fd563b50bcebc Reviewed-on: https://go-review.googlesource.com/c/net/+/446256 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
Update net/http to enable tests that pass with the latest update to the vendored x/net. Update a few tests: Windows apparently doesn't guarantee that time.Since(time.Now()) is >=0, so to set a definitely-expired write deadline, use a time firmly in the past rather than now. Put a backoff loop on TestServerReadTimeout to avoid failures when the timeout expires mid-TLS-handshake. (The TLS handshake timeout is set to min(ReadTimeout, WriteTimeout, ReadHeaderTimeout); there's no way to set a long TLS handshake timeout and a short read timeout.) Don't close the http.Server in TestServerWriteTimeout while the handler may still be executing, since this can result in us getting the wrong error. Change the GOOS=js fake net implementation to properly return ErrDeadlineExceeded when a read/write deadline is exceeded, rather than EAGAIN. For #49837 For #54136 Change-Id: Id8a4ff6ac58336ff212dda3c8799b320cd6b9c19 Reviewed-on: https://go-review.googlesource.com/c/go/+/449935 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
After 1 second, some error from
io.ReadAll
inhandler
indicating the request had timed out during reading.What did you see instead?
The call to
io.ReadAll
completed in 10 seconds with no error.The text was updated successfully, but these errors were encountered: