Skip to content

internal/github tests share http.DefaultTransport across parallel tests #401

Description

@jongio

Problem

urlRewriteTransport.RoundTrip in internal/github/client_test.go:33 delegates to the process-global http.DefaultTransport. Every mock client built by setupMockClient therefore shares one connection pool, so all t.Parallel() tests in the package are coupled to each other's httptest server teardown.

This produces intermittent race-detector CI failures that look like real regressions on unrelated PRs.

Evidence

Observed in run 30752139053 on PR #395:

--- FAIL: TestClient_DeleteBranch_Success/long_branch_name
    delete branch "very-long-branch-name-with-many-parts":
    Delete "https://api.github.com/repos/owner/repo/git/refs/heads/very-long-branch-name-with-many-parts":
    net/http: HTTP/1.x transport connection broken: http: CloseIdleConnections called

It passed on macOS in the same run and passed on re-run with no code change. PR #395 touched only cmd/clean.go, cmd/clean_test.go, and a docs page, so it could not have caused a failure in internal/github.

Fix

Give each mock client its own http.Transport instead of http.DefaultTransport, and close it in t.Cleanup alongside the server.

Acceptance criteria

  • urlRewriteTransport uses a per-instance http.Transport, not the global default.
  • setupMockClient closes idle connections for its own transport on cleanup.
  • go test ./internal/github/ -race -count=20 passes consistently.

Activity

  1. added a commit that references this issue on Aug 27, 2026
    52c7f72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions