]> Cypherpunks repositories - gostls13.git/commit
net/http: fix WaitGroup race in TestTransportNoReuseAfterEarlyResponse
authorDmitri Shuralyov <dmitshur@golang.org>
Sat, 24 Jan 2026 18:03:14 +0000 (13:03 -0500)
committerGopher Robot <gobot@golang.org>
Fri, 6 Feb 2026 22:53:30 +0000 (14:53 -0800)
commitcbb37e310e2edd7148c8501567e190746e6d98d2
treec74a8112ecca81e4f6651f56dcdf5e9d1e0ae718
parentd1ec0ecec956eb10c3daf40160193daf407c7614
net/http: fix WaitGroup race in TestTransportNoReuseAfterEarlyResponse

The remaining race reported in go.dev/issue/66519 is that it's possible
for copying.Wait to start running before all copying.Add calls complete.
It happens infrequently as is, but padding both Wait and Add calls with
a 100 ms sleep makes it highly reproducible.

Arranging the Add call to happen before responding "foo" to the POST
request should be enough to guarantee that Wait doesn't start running
until all Add calls have already happened.

While here, delete a blank line that gets more in the way of reading
error handling code than it helps.

For #64252.
Fixes #66519 (optimistically).

Change-Id: Ibf264d8cc5ffc2495e8ae8e66a15591310c65e71
Reviewed-on: https://go-review.googlesource.com/c/go/+/739060
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
src/net/http/client_test.go
src/net/http/transport_test.go