Repository navigation
Description
What happened
During the CI run for PR #242 on 2026-09-21, the Go 1.24 Unit + Integration Tests job (run 35624800904) timed out after 15 minutes. The stack trace pointed to TestOllamaAdapter_ContextCancellation in internal/aireport/adapter_ollama_test.go. The CI log shows httptest.Server blocked in Close after 5 seconds, waiting for connections with an active TCP connection that never drained. The subsequent run (35627742889) on the same commit passed, confirming this is a flaky test, not a real regression.
What could go better
The test has two structural issues causing intermittent hangs:
-
Missing synchronization: The test calls
cancel()on the line immediately after spawning the goroutine that callsadapter.Format(ctx, ...). There is no signal to confirm the HTTP request has arrived at the server before cancellation fires. Under CI resource pressure, the scheduler timing can cause the server handler's<-r.Context().Done()to never see the cancellation propagate through the HTTP transport, leaving the handler goroutine blocked. -
Missing test-level timeout: The
<-donechannel receive has no timeout. If the goroutine hangs, the test hangs indefinitely until the Go test binary's-timeoutflag kills the entire binary — which in CI is 15 minutes.
The failure occurred only on Go 1.24 (not 1.25), suggesting a Go version difference in how httptest.Server.Close() propagates connection shutdown to handler goroutines. This is a test-fixture resilience issue, not a production code bug.
Confidence: HIGH — the root cause is clearly visible in the test structure and confirmed by the CI log showing the blocked server connection.
Proposed change
In internal/aireport/adapter_ollama_test.go, apply two fixes to TestOllamaAdapter_ContextCancellation:
-
Add a synchronization channel to ensure the HTTP request is in-flight before cancelling:
- Add
started := make(chan struct{})before the server handler. - In the handler,
close(started)before<-r.Context().Done(). - After spawning the goroutine,
<-startedbefore callingcancel().
- Add
-
Add a timeout on the done channel receive to fail fast with a clear message instead of hanging:
- Replace
err := <-donewith aselectthat includes acase <-time.After(5 * time.Second): t.Fatal("Format did not return after context cancellation").
- Replace
Both fixes should be applied together — the synchronization ensures deterministic behavior, and the timeout ensures the test fails fast (in 5 seconds with a clear message) rather than hanging the CI job for 15 minutes if something still goes wrong.
Validation criteria
- Run
go test -race -count=10 -run TestOllamaAdapter_ContextCancellation ./internal/aireport/on both Go 1.24 and Go 1.25 — all 10 iterations should pass without hanging. - The next 3 CI runs on
mainshould not show any timeout in the Unit + Integration Tests job forinternal/aireport. - If the test fails, it should fail within 5 seconds with the message
Format did not return after context cancellation, not after 15 minutes with a generic timeout.
Generated by retro agent from #242
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
fullsend-ai-triage commentedon Sep 21, 2026
🤖 Finished Triage · ✅ Success · Started 5:55 PM UTC · Completed 5:59 PM UTC
Commit:
76f8ca9· View workflow run →Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.57
fullsend-ai-triage commentedon Sep 21, 2026
Triage Summary
Severity: medium — flaky CI, no production impact.
The root cause analysis in this retro issue is accurate. Reading the test source confirms both structural gaps:
cancel()races ahead of the HTTP request, and the<-donereceive has no timeout guard.Proposed Test Case
All 10 iterations should complete within seconds. On failure, the test should exit in ≤5s with
"Format did not return after context cancellation"rather than hanging for 15 minutes.Next steps:
/fs-code— agent creates a PR to implement this issue/fs-code <your instruction>— agent implements with your specific guidancefullsend-ai-coder commentedon Sep 21, 2026
🤖 Finished Code · ✅ Success · Started 6:00 PM UTC · Completed 6:11 PM UTC
Commit:
76f8ca9· View workflow run →Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.66
fix(#272): eliminate race condition in TestOllamaAdapter_ContextCance…
fix(#272): eliminate race condition in TestOllamaAdapter_ContextCance…
Merge pull request #274 from unbound-force/agent/272-fix-ollama-test-…