Skip to content

Commit 10ea372

Browse files
authored
fix(shared/http): close idle connections to stop updater connection leak (#2648)
Each Download call built a fresh http.Transport whose pool was discarded on return, so net/http returned the keep-alive connection to a pool that nothing ever reclaimed. The updater polls the dependencies endpoint every 5 minutes, leaking one idle connection per poll until endpoints accumulated thousands of ESTABLISHED sockets. DownloadAndVerify doubles the leak (two downloads per call). Close idle connections explicitly on return (DisableCompression already set to match the per-call transport). Same fix as the v11 backport.
1 parent 24de4f2 commit 10ea372

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎shared/http/download.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ func Download(url, destDir, filename string, opts DownloadOptions) error {
4343
TLSClientConfig: &tls.Config{
4444
InsecureSkipVerify: opts.SkipTLSVerify,
4545
},
46+
DisableCompression: true,
4647
}
4748

4849
client := &http.Client{
4950
Timeout: opts.Timeout,
5051
Transport: transport,
5152
}
5253

54+
defer transport.CloseIdleConnections()
55+
5356
req, err := http.NewRequest(http.MethodGet, url, nil)
5457
if err != nil {
5558
return fmt.Errorf("error creating request: %w", err)

0 commit comments

Comments
 (0)