Skip to content

fetch: honor HTTP_PROXY and tighten failure modes#27

Merged
andrew merged 1 commit into
mainfrom
fetcher-http-proxy-support
May 12, 2026
Merged

fetch: honor HTTP_PROXY and tighten failure modes#27
andrew merged 1 commit into
mainfrom
fetcher-http-proxy-support

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 12, 2026

The custom http.Transport in fetch.NewFetcher was constructed without Proxy: http.ProxyFromEnvironment, so it silently ignored HTTP_PROXY, HTTPS_PROXY and NO_PROXY. The metadata client in client/client.go uses http.DefaultTransport so metadata requests were unaffected, but every ecosystem's artifact download path runs through this Fetcher and would hang behind corporate proxies until the 5 minute client timeout. Reported in git-pkgs/proxy#118 for PyPI; the same bug affected all ecosystems.

This PR also tightens a few other things in the same client:

  • Wrap the last underlying dial error rather than returning an opaque failed to dial any resolved IP, so future network failures self-diagnose.
  • Add a 60s ResponseHeaderTimeout so an upstream that accepts the TCP connection but never replies fails in 60s instead of 5min.
  • Add Fetcher.Close so the DNS refresh goroutine can be stopped. Previously each NewFetcher leaked one goroutine for the process lifetime.

- Set Transport.Proxy to http.ProxyFromEnvironment so HTTP_PROXY,
  HTTPS_PROXY and NO_PROXY env vars are honored on artifact downloads.
  Without this, the custom http.Transport silently ignored proxy env
  vars while the metadata client (using http.DefaultTransport) honored
  them, causing artifact downloads to hang behind corporate proxies.
- Wrap the last underlying dial error instead of returning an opaque
  "failed to dial any resolved IP" message.
- Add a 60s ResponseHeaderTimeout so hung upstreams fail fast rather
  than waiting the full 5 minute client timeout.
- Make the DNS refresh goroutine stoppable via a new Fetcher.Close
  method to avoid leaking a goroutine per Fetcher.
@andrew andrew merged commit 199ade6 into main May 12, 2026
5 checks passed
@andrew andrew deleted the fetcher-http-proxy-support branch May 12, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant