python
network_error
ai_generated
partial
ClientDisconnected: Client disconnected while sending request body
ID: python/starlette-request-client-disconnect
80%Fix Rate
84%Confidence
0Evidence
2026-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The client closes the connection before the request body is fully received.
generic中文
客户端在请求体完全接收之前关闭了连接。
Workarounds
-
80% success
Handle the exception gracefully and log it: except ClientDisconnected: logger.warning('Client disconnected') -
70% success
Use a middleware to catch and return a 499 status code
Dead Ends
Common approaches that don't work:
-
50% fail
The request is incomplete; continuing may cause data corruption.
-
30% fail
The client is gone; timeout won't help.