Commit 9a1a3c4
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 239d682 commit 9a1a3c4
File tree
1 file changed
+4
-0
lines changed1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
277 | 281 | | |
278 | 282 | | |
279 | 283 | | |
| |||
0 commit comments