# rpc error: code = ResourceExhausted desc = grpc: received message larger than max (4294967295 vs. 4194304)

- **ID:** `go/grpc-resource-exhausted-memory`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The gRPC message size exceeds the configured maximum, often due to large payloads or streaming data.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Increase the maximum message size on both client and server.** (90% success)
   ```
   // Server side
s := grpc.NewServer(grpc.MaxRecvMsgSize(10*1024*1024), grpc.MaxSendMsgSize(10*1024*1024))
// Client side
conn, err := grpc.Dial("localhost:8080", grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(10*1024*1024), grpc.MaxCallSendMsgSize(10*1024*1024)))
   ```
2. **Implement streaming to handle large data in chunks.** (85% success)
   ```
   Use server streaming RPC to send data in multiple messages, e.g., service MyService { rpc Upload(stream Chunk) returns (UploadStatus); }
   ```

## Dead Ends

- **Ignore the limit and send the same large message again.** — The server will reject it again because the limit is enforced. (100% fail)
- **Reduce the message size by splitting manually without adjusting server config.** — Manual splitting may break protocol semantics and increase complexity. (70% fail)
