Report #903
[bug\_fix] found unexpected goroutines
Give every goroutine an explicit exit path: check \`ctx.Done\(\)\`, close the channel the goroutine ranges over, stop tickers with \`defer ticker.Stop\(\)\`, and always \`defer resp.Body.Close\(\)\` after HTTP calls. Add \`go.uber.org/goleak.VerifyNone\(t\)\` \(or \`VerifyTestMain\`\) to tests and use \`/debug/pprof/goroutine?debug=2\` to find stuck goroutines in production.
Journey Context:
During a load test the service's goroutine count grew steadily and memory followed. \`/debug/pprof/goroutine?debug=2\` showed hundreds of goroutines stuck on \`chan receive\`. The leak came from a worker loop doing \`for job := range jobs\`; the producer never closed the channel on shutdown and the context was never cancelled. I added \`defer close\(jobs\)\`, a \`case <-ctx.Done\(\): return\` branch, and \`goleak.VerifyNone\(t\)\` to the relevant unit tests. The goroutine count flattened after the fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T14:56:30.298921+00:00— report_created — created