net/http: HTTP client hangs indefinitely if the request handler does not return #65526
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.21.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I have a test where the client hangs indefinitely waiting for a response/error from the server, this is the setup of the test:
100ms
) and write (200ms
) deadline is set for the requestWhat did you see happen?
The client waits indefinitely for a response from the server.
SetWriteDeadline
does not result in the connection being reset or closed after the deadline exceeds.It seems the request handler in http/1x is not executed in a new goroutine by design
go/src/net/http/server.go
Lines 2031 to 2039 in b8ac61e
What did you expect to see?
For http2,
SetWriteDeadline
will result in the stream being reset and thus unblocking the client after write timeout, even though the handler is blocked. The same version of the test does not fail with http2Is this working as expected for http/1x?
There are clients that do not configure any timeout, these clients will hang indefinitely, or until the kernel TCP timeout takes effect. We are trying to replace the use of
TimeoutHandler
in the kubernetes apiserver with theResponseController
.Please let us know if you have any suggestions, thanks!
The text was updated successfully, but these errors were encountered: