# fatal error: all goroutines are asleep - deadlock! (blocked on chan receive)

- **ID:** `go/fatal-error-all-goroutines-are-asleep-deadlock-blocked-`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

main receives from a channel that no goroutine ever sends to, e.g. a producer goroutine exited early due to an error or a nil channel was used.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |
| 1.23 | active | — | — |

## Workarounds

1. **** (94% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
select {
case v := <-ch:
    use(v)
case <-ctx.Done():
    return ctx.Err()
}
   ```
2. **** (92% success)
   ```
   go func() {
    defer close(ch)
    for _, x := range items {
        ch <- x
    }
}()
for v := range ch { use(v) }
   ```

## Dead Ends

- **** — Buffer only helps if a sender exists; with no sender, receive still blocks forever. (85% fail)
- **** — An empty select blocks forever too, converting deadlock into a silent hang. (90% fail)
