Title: Handle connection errors in StreamableHTTP post_writer by omar-y-abdi · Pull Request #2282 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Handle connection errors in StreamableHTTP post_writer by omar-y-abdi · Pull Request #2282 · modelcontextprotocol/python-sdk
X Title: Handle connection errors in StreamableHTTP post_writer by omar-y-abdi · Pull Request #2282 · modelcontextprotocol/python-sdk
Description: Fixes #2273. Fixes #2110 When the server becomes unreachable mid-session, _handle_post_request raises a connection error (e.g. httpx.ConnectError). Without this fix, the exception propagates into the anyio task group and tears down the entire transport, causing an infinite cancellation retry loop with sustained high CPU use. This wraps handle_request_async in a try/except that catches Exception (re-raising cancellation) and forwards the error to the read stream via read_stream_writer.send(exc). The client session then receives it as a normal error instead of crashing. This is the same approach used elsewhere in the transport (e.g. the outer post_writer catch). Includes a test that connects to a dead port, sends a request, and verifies the connection error is forwarded to the read stream.
Open Graph Description: Fixes #2273. Fixes #2110 When the server becomes unreachable mid-session, _handle_post_request raises a connection error (e.g. httpx.ConnectError). Without this fix, the exception propagates into t...
X Description: Fixes #2273. Fixes #2110 When the server becomes unreachable mid-session, _handle_post_request raises a connection error (e.g. httpx.ConnectError). Without this fix, the exception propagates into t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2282
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b49f1685-33c4-5269-796a-e8b3a06feefb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E2AE:9D839:412F64:59D4D2:6A6107AA |
| html-safe-nonce | 63dfe86e80d5a67910a3c499989ba8a1776ec6c290fea9112b1c38c20868c9c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkFFOjlEODM5OjQxMkY2NDo1OUQ0RDI6NkE2MTA3QUEiLCJ2aXNpdG9yX2lkIjoiNDYwMzYyMzI0NTYxMTA3NTQ5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 06781a4178c139fd41211b7f4912f14216bf6c00866aa212db3f6c61fcca15f9 |
| hovercard-subject-tag | pull_request:3386925174 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2282/files |
| twitter:image | https://avatars.githubusercontent.com/u/204912262?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/204912262?s=400&v=4 |
| og:image:alt | Fixes #2273. Fixes #2110 When the server becomes unreachable mid-session, _handle_post_request raises a connection error (e.g. httpx.ConnectError). Without this fix, the exception propagates into t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9029e642b81338577ec563d0cede79b18d6f1471b9ecdd8e364313b9cc67dd06 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0af5dc40dcb0f82accd92a80d9517702c13746f0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width