# rpc error: code = Canceled desc = context canceled

- **ID:** `go/grpc-canceled-by-client`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The client canceled the RPC (via context cancel, HTTP/2 RST_STREAM, or parent context timeout) before the server finished.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/grpc 1.48+ | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Check ctx.Err() in the server handler and exit early:
select {
case <-ctx.Done():
    return nil, status.FromContextError(ctx.Err()).Err()
default:
}
// continue processing
   ```
2. **** (85% success)
   ```
   Distinguish client cancel from server-side timeout by inspecting the parent context; treat codes.Canceled as INFO in logs and metrics.
   ```

## Dead Ends

- **** — If the caller intentionally canceled (e.g., user closed the page), retrying wastes resources. (80% fail)
- **** — Canceled is a normal client behavior; alerting creates noise. (85% fail)
