Skip to content

fix(test): stop sharing http.DefaultTransport across parallel tests#85

Merged
joaomdsg merged 1 commit into
mainfrom
fix/test-shared-transport-flake
Jun 2, 2026
Merged

fix(test): stop sharing http.DefaultTransport across parallel tests#85
joaomdsg merged 1 commit into
mainfrom
fix/test-shared-transport-flake

Conversation

@joaomdsg

@joaomdsg joaomdsg commented Jun 2, 2026

Copy link
Copy Markdown
Member

Summary

httptest.Server.Close calls http.DefaultTransport.CloseIdleConnections() as cleanup. All test files use t.Parallel() + http.Get/http.Post/http.DefaultClient (shared DefaultTransport), so one test's server teardown can sever an idle connection another test is about to reuse — the transport connection broken: CloseIdleConnections called flake that failed CI on main (mw HSTS test).

Mechanical fix across 20 test files: every request now goes through its own server.Client(), whose transport no other test can touch. vt already used dedicated transports and is untouched.

Testing

  • go vet ./... clean
  • go test -count=3 -parallel 16 ./... — zero failures across 3 stress runs

httptest.Server.Close calls DefaultTransport.CloseIdleConnections as
cleanup, so any parallel test using http.Get / http.DefaultClient can
have its idle connection severed by an unrelated test's server teardown
— surfacing as 'transport connection broken: CloseIdleConnections
called' (seen on main CI in mw's HSTS test). Every test now uses its
own server's Client(), whose transport no other test can touch.
@joaomdsg
joaomdsg merged commit 6d9e4ab into main Jun 2, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the fix/test-shared-transport-flake branch June 2, 2026 13:49
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