-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: req.Body.Close called multiple times in http1, sometimes not called by the time Do returns on error #26408
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
Comments
Also, I couldn't get this to trigger using a small body. I did not dig into why exactly that is. |
/cc @bradfitz |
Moving to Go 1.12, as I see no mention of this being a regression since Go 1.10. |
(not a regression, also note related to #19186) |
Change https://golang.org/cl/124315 mentions this issue: |
Change https://golang.org/cl/125635 mentions this issue: |
I lost interest in pursuing this after the initial round of reviews took quite a long time.. Maybe it doesn't happen anymore on tip, maybe it does. |
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: