From 59202c4204205ee019cf25efcb814b72c8703f4b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 12 Oct 2020 21:09:18 -0400 Subject: [PATCH] net/http: deflake TestServerEmptyBodyRace_h1, or at least try Fixes #22540. For #33585. Change-Id: I504b5a91ce1a39cd4ffd2380178a1b8f82f49dd3 Reviewed-on: https://go-review.googlesource.com/c/go/+/261698 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov --- src/net/http/serve_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index cbd3101f27..d84804c2e9 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -4275,8 +4275,14 @@ func testServerEmptyBodyRace(t *testing.T, h2 bool) { defer wg.Done() res, err := cst.c.Get(cst.ts.URL) if err != nil { - t.Error(err) - return + // Try to deflake spurious "connection reset by peer" under load. + // See golang.org/issue/22540. + time.Sleep(10 * time.Millisecond) + res, err = cst.c.Get(cst.ts.URL) + if err != nil { + t.Error(err) + return + } } defer res.Body.Close() _, err = io.Copy(ioutil.Discard, res.Body)