aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicholas S. Husin <nsh@golang.org>2026-04-13 13:30:33 -0400
committerNicholas Husin <nsh@golang.org>2026-04-13 12:51:05 -0700
commit81e9cc392e5787493094f1687341a626936ffdb3 (patch)
tree3aa5d7e32d3db8df210d3cb8c559ce363df89828 /src
parente7c75c3ae80338a635051770052652870679aaf5 (diff)
downloadgo-81e9cc392e5787493094f1687341a626936ffdb3.tar.xz
net/http: fix wrong context being used when shutting down HTTP/3 server
t.Context was accidentally used within a t.Cleanup. This is a mistake since t.Context will always have been cancelled by the time t.Cleanup runs. This is likely the reason for flakiness in some builders: our HTTP/3 finishes before QUIC connections can finish closing asynchronously, which are then detected as goroutine leaks. To account for this, also make the shutdown context timeout more generous. For #70914 Change-Id: I0e5f06a47ef25c5df535543fc1e602f16a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/766620 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/net/http/clientserver_test.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go
index ca68096e2b..0bcc950103 100644
--- a/src/net/http/clientserver_test.go
+++ b/src/net/http/clientserver_test.go
@@ -280,8 +280,11 @@ func newClientServerTest(t testing.TB, mode testMode, h Handler, opts ...any) *c
listenAddr := <-listenAddrCh
cst.ts.URL = "https://" + listenAddr
t.Cleanup(func() {
- // Same timeout as in HTTP/2 goAwayTimeout when shutting down in tests.
- ctx, cancel := context.WithTimeout(t.Context(), 25*time.Millisecond)
+ // Give a relatively generous timeout. If the timeout is too short,
+ // the test might return before QUIC connections can finish closing
+ // asynchronously in some builders. The open connections will cause
+ // TestMain to detect a goroutine leak and fail.
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
cst.ts.Config.Shutdown(ctx)
})