{
  "id": "go/grpc-resource-exhausted-message-too-large",
  "signature": "rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5242881 vs. 4194304)",
  "signature_zh": "rpc 错误：code = ResourceExhausted desc = grpc: 收到的消息大于最大值（5242881 对 4194304）",
  "regex": "rpc\\ error:\\ code\\ =\\ ResourceExhausted\\ desc\\ =\\ grpc:\\ received\\ message\\ larger\\ than\\ max\\ \\(5242881\\ vs\\.\\ 4194304\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "gRPC 默认最大接收消息大小为 4MB。服务端或客户端收到的序列化消息超过了该限制。常见于 protobuf 中嵌入的大型 repeated 字段或二进制数据。",
  "versions": [
    {
      "version": "google.golang.org/grpc 1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The limit applies to the decompressed message size on receive; compression does not change the post-decompression size.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Without a defined chunking protocol (e.g., streaming with sequence numbers), the receiver cannot reconstruct the message.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "// server\ns := grpc.NewServer(grpc.MaxRecvMsgSize(16 * 1024 * 1024))\n// client\nconn, _ := grpc.Dial(addr, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16*1024*1024)))",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "stream, err := client.Upload(ctx)\nfor _, chunk := range chunks {\n    if err := stream.Send(&pb.Chunk{Data: chunk}); err != nil { return err }\n}\nresp, err := stream.CloseAndRecv()",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}