go resource_error ai_generated true

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

ID: go/grpc-resource-exhausted-receive-buffer

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-03-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active

Root Cause

The gRPC message size exceeds the default maximum of 4 MB (4194304 bytes). The server or client has not adjusted the max receive message size.

generic

中文

gRPC 消息大小超过默认最大值 4 MB(4194304 字节)。服务器或客户端未调整最大接收消息大小。

Workarounds

  1. 95% success
    grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*10)) on client; grpc.MaxRecvMsgSize(1024*1024*10) in server options.
  2. 80% success
    Implement a custom streaming or pagination mechanism.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Compression may not always be possible or sufficient; the underlying data may still exceed limits after compression.

  2. 95% fail

    The message size will not change, so the error will recur.