fix: build HTTP transport explicitly to avoid HTTP/2 leak#443
Conversation
…HTTP/2 leak http.DefaultTransport can be mutated at boot by other libraries (notably OpenTelemetry registering an h2 handler in TLSNextProto). Cloning it inherited that handler, so HTTPS connections negotiated HTTP/2 via ALPN and hit the stdlib hpack encoder issue under the concurrent-goroutine usage pattern of this client — reproduced in production on 2026-04-10 (61 errors on reporter-manager, 14 on reporter-worker, circuit-breaker cascade, 503s). Replace the Clone()-based construction with an explicit *http.Transport. TLSNextProto is initialized to a non-nil empty map (the stdlib opt-out signal). Proxy, DialContext, TLS, pool and timeout settings are now set explicitly, no longer inherited from a mutable global. HTTP/1.1 is the deliberate choice for this client because middleware and async revalidation share the same host concurrently. Adds client_transport_test.go with regression tests that contaminate http.DefaultTransport with an h2 handler and assert it does not leak into the client, plus pinning tests for pool and timeout defaults. Refs: docs/lib-commons/incidents/2026-04-10-http2-protocol-mismatch.md Generated-by: Claude AI-Model: claude-opus-4-7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe HTTP client factory function was refactored to construct a new explicit Changes
Comment |
|
This PR has had no activity for 20 days and is now marked stale. It will be closed in 7 days unless updated. Add the Learn more about the routine and exempt labels: https://github.com/LerianStudio/github-actions-shared-workflows/blob/main/instructions/repository-routines.md |
http.DefaultTransport can be mutated at boot by other libraries (notably OpenTelemetry registering an h2 handler in TLSNextProto). Cloning it inherited that handler, so HTTPS connections negotiated HTTP/2 via ALPN and hit the stdlib hpack encoder issue under the concurrent-goroutine usage pattern of this client — reproduced in production on 2026-04-10 (61 errors on reporter-manager, 14 on reporter-worker, circuit-breaker cascade, 503s).
Replace the Clone()-based construction with an explicit *http.Transport. TLSNextProto is initialized to a non-nil empty map (the stdlib opt-out signal). Proxy, DialContext, TLS, pool and timeout settings are now set explicitly, no longer inherited from a mutable global. HTTP/1.1 is the deliberate choice for this client because middleware and async revalidation share the same host concurrently.
Adds client_transport_test.go with regression tests that contaminate http.DefaultTransport with an h2 handler and assert it does not leak into the client, plus pinning tests for pool and timeout defaults.
Pull Request Checklist
Pull Request Type
Checklist
Please check each item after it's completed.
Additional Notes
Obs: Please, always remember to target your PR to develop branch instead of main.