net/http: req.Body.Close called multiple times in http1, sometimes not called by the time Do returns on error #26408
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?go version devel +c80897b691 Mon Jul 16 20:29:54 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
In net/http/clientserver_test.go
What did you expect to see?
No test failure.
What did you see instead?
transferWriter's WriteBody calls its BodyCloser's Close if there was no write error (close one). That function then returns nil, at which point the
persistConn
flushes buffered data. That can error, and the error causes acloseBody
.Unrelated but visible in the same test, sometimes
close
is not called by the time the request returns. I'm not sure if this is expected, and it may be fine. If so, the test iterations can be dropped significantly and the switch / failure cases modified. It does close shortly after return (which is visible with a sleep and then a re-check). I would expect this to be show up in the race detector but I can't get it to show up (I also can't get any output / prints to show up when running tests in the stdlib).The text was updated successfully, but these errors were encountered: