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

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

## Root Cause

The default gRPC max receive message size is 4MB. The server or client received a serialized message exceeding this limit. Common with large repeated fields or blobs embedded in protobuf.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/grpc 1.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   // server
s := grpc.NewServer(grpc.MaxRecvMsgSize(16 * 1024 * 1024))
// client
conn, _ := grpc.Dial(addr, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16*1024*1024)))
   ```
2. **** (85% success)
   ```
   stream, err := client.Upload(ctx)
for _, chunk := range chunks {
    if err := stream.Send(&pb.Chunk{Data: chunk}); err != nil { return err }
}
resp, err := stream.CloseAndRecv()
   ```

## Dead Ends

- **** — The limit applies to the decompressed message size on receive; compression does not change the post-decompression size. (75% fail)
- **** — Without a defined chunking protocol (e.g., streaming with sequence numbers), the receiver cannot reconstruct the message. (60% fail)
