Bug
go test -race -count=1 -timeout 240s ./cmd/sin-code/internal/ times out
(4 min) under -race. One of the 240-second-package-tests hangs and never
finishes. Suspect: HTTP server test that doesn't shut down its listener
(via httptest.NewServer without t.Cleanup), or subprocess re-exec that
never gets killed.
Reproduce
go test -race -count=1 -timeout 60s -v ./cmd/sin-code/internal/ 2>&1 | tail -50
Last lines before the hang typically show the test name and a goroutine
blocked on a channel read or HTTP accept.
Expected
All tests in the package complete in <10s under -race.
Actual
Test runner hits the 60s / 240s timeout without ever returning.
Fix
- Find the hanging test via verbose run
- Add
srv.Close() via t.Cleanup for httptest servers
- Add
cmd.Process.Kill() via t.Cleanup for subprocess exec
- Convert
defer to t.Cleanup so it fires on panic too
- Verify:
go test -race -count=3 -timeout 90s ./cmd/sin-code/internal/ — all 3 runs green
Cross-refs
- Related: PR fix(v3.6.0-internal-race-hang) (in progress)
- AGENTS.md §3 mandate M7 (race-free concurrency)
Bug
go test -race -count=1 -timeout 240s ./cmd/sin-code/internal/times out(4 min) under -race. One of the 240-second-package-tests hangs and never
finishes. Suspect: HTTP server test that doesn't shut down its listener
(via httptest.NewServer without t.Cleanup), or subprocess re-exec that
never gets killed.
Reproduce
Last lines before the hang typically show the test name and a goroutine
blocked on a channel read or HTTP accept.
Expected
All tests in the package complete in <10s under -race.
Actual
Test runner hits the 60s / 240s timeout without ever returning.
Fix
srv.Close()viat.Cleanupfor httptest serverscmd.Process.Kill()viat.Cleanupfor subprocess execdefertot.Cleanupso it fires on panic toogo test -race -count=3 -timeout 90s ./cmd/sin-code/internal/— all 3 runs greenCross-refs