# fatal error: all goroutines are asleep - deadlock! (context canceled)

- **ID:** `go/goroutine-context-cancel-not-checked`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Goroutines block on channel operations after context is canceled, without checking cancellation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.7 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Always include ctx.Done() in select** (95% success)
   ```
   select {
case <-ch:
case <-ctx.Done():
    return ctx.Err()
}
   ```
2. **Use context.WithTimeout to automatically cancel** (90% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
select {
case <-ch:
case <-ctx.Done():
    // timeout
}
   ```

## Dead Ends

- **Ignoring context in select** — Context cancellation doesn't automatically unblock other channels. (90% fail)
- **Using time.Sleep to wait for cancellation** — Sleep doesn't handle cancellation; goroutine still blocks. (80% fail)
