Commit a3f2133
fix: handle EndOfStream and ClosedResourceError in send_request
Fixes #1717
The `send_request` method only catches `TimeoutError` from the
`response_stream_reader.receive()` call. If `receive()` raises
`EndOfStream` or `ClosedResourceError` (e.g., when the connection
closes unexpectedly), these exceptions propagate without being
caught, potentially leaving `response_or_error` unassigned and
causing an `UnboundLocalError` at the subsequent isinstance check.
This adds explicit handling for these stream closure exceptions,
converting them to `McpError` with `CONNECTION_CLOSED` error code.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent a1d330d commit a3f2133
File tree
1 file changed
+10
-0
lines changed1 file changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
283 | 293 | | |
284 | 294 | | |
285 | 295 | | |
| |||
0 commit comments