net/http: Unexpected "define Request.GetBody to avoid this error" error after setting Request.GetBody #69412
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.23.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I have not been able to make a stand alone example, but will walk through the exact code path that is triggered.
The offending code is as follows:
Which under very particular circumstances, the call to
client.Do
returns the errorhttp2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error
, even thoughGetBody
has been set.To get here, the request must be redirected followed by a retry-able HTTP/2 error such as GOAWAY. (I believe it also may require a cached HTTP/2 connection from a previous call).
How I managed this was the following setup:
Load generating go program (the one getting the error) with at least two go routines sending on the same client
<->nginx minikube ingress
<->some kubernetes service
The code path is as follows:
GetBody
function does not get set when the original request is copied here.http2shouldRetryRequest
is called.GetBody
was not copied on the redirect, this section fails to copy the body, and we reach the resulting error here.What did you see happen?
I received an error telling me to set
GetBody
to avoid said error, even thoughGetBody
had in fact been set.What did you expect to see?
I would expect either the
GetBody
function pointer to be copied on redirect, or the error returned to better reflect the actual error condition.The text was updated successfully, but these errors were encountered: