# INTERNAL: grpc: 解压后的消息大小 1048576 超过最大限制 524288

- **ID:** `grpc/compression-message-size-mismatch`
- **领域:** grpc
- **类别:** resource_error
- **错误码:** `EDECOMPRESS`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

解压缩后，消息大小超过了配置的最大接收消息大小，即使压缩后的大小在限制内，也会导致内部错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.58.0 | active | — | — |
| gRPC v1.61.0 | active | — | — |
| gRPC v1.64.0 | active | — | — |

## 解决方案

1. ```
   Increase the client's max receive message size to accommodate the decompressed payload: `channel = grpc.insecure_channel(target, options=[('grpc.max_receive_message_length', 2 * 1024 * 1024)])`
   ```
2. ```
   On the server side, reduce the uncompressed message size by splitting large responses or using streaming instead of unary calls.
   ```
3. ```
   If using gRPC-Web, ensure the proxy's max buffer size is also increased (e.g., Envoy's `max_request_body_size`).
   ```

## 无效尝试

- **Increasing the client's max send message size to match the decompressed size.** — The error is on the receiving side; max send size controls outgoing messages, not incoming decompressed messages. (90% 失败率)
- **Disabling compression on the server side to avoid decompression entirely.** — This may break clients that rely on compression for performance; it also doesn't address the root cause of the size limit. (50% 失败率)
- **Setting the environment variable GRPC_MAX_RECEIVE_MESSAGE_LENGTH to a value lower than the compressed size.** — This would reject the message before decompression, worsening the issue. (95% 失败率)
