python
network_error
ai_generated
partial
客户端断开连接:发送请求体时客户端断开连接
ClientDisconnected: Client disconnected while sending request body
ID: python/starlette-request-client-disconnect
80%修复率
84%置信度
0证据数
2026-02-14首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
客户端在请求体完全接收之前关闭了连接。
English
The client closes the connection before the request body is fully received.
解决方案
-
80% 成功率
Handle the exception gracefully and log it: except ClientDisconnected: logger.warning('Client disconnected') -
70% 成功率
Use a middleware to catch and return a 499 status code
无效尝试
常见但无效的做法:
-
50% 失败
The request is incomplete; continuing may cause data corruption.
-
30% 失败
The client is gone; timeout won't help.