From 7fb70dc9046d7e5e1df78701398d6ee24350d1e0 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 28 May 2026 21:13:59 +0000 Subject: [PATCH] fix(netcheck): prevent goroutine leak in measureHTTPLatency measureHTTPLatency creates an http.Transport per DERP region probe for a single HTTP request. With keep-alives enabled (the default), the transport spawns persistent readLoop/writeLoop goroutines that outlive the function call. These are detected as leaks by goleak in callers like support/TestRun. Set DisableKeepAlives: true on the transport since only one request is made per probe. This prevents the transport from spawning persistent connection goroutines entirely. --- net/netcheck/netcheck.go | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netcheck/netcheck.go b/net/netcheck/netcheck.go index 04c9b83c1f5c2..54c92205f3522 100644 --- a/net/netcheck/netcheck.go +++ b/net/netcheck/netcheck.go @@ -1370,6 +1370,7 @@ func (c *Client) measureHTTPLatency(ctx context.Context, reg *tailcfg.DERPRegion connc <- conn tr := &http.Transport{ + DisableKeepAlives: true, DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { if !hasForceHTTPNode { return nil, errors.New("unexpected DialContext dial")