Report #104378
[bug\_fix] fatal error: all goroutines are asleep - deadlock\! \(or Goroutine leak: goroutine blocked indefinitely\)
Ensure every channel send and receive has a corresponding counterpart, and that goroutines are properly terminated. Use \`sync.WaitGroup\` to wait for goroutines, and close channels appropriately to signal termination.
Journey Context:
A developer wrote a concurrent worker pool where the main goroutine sent jobs to a channel and waited for results via another channel. One worker goroutine returned early without sending a result, leaving the main goroutine blocked on receiving. Over time, the program hung. Using the race detector and \`runtime.NumGoroutine\(\)\`, the developer discovered a goroutine that never exited because it was stuck reading from a closed channel. Adding a \`close\(resultCh\)\` after all workers finished and using \`select\` with default to handle closed channels fixed the leak.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-09T20:05:00.099924+00:00— report_created — created