René's URL Explorer Experiment


Title: [v1.x] Resolve a failed SSE message POST instead of hanging the caller by Mart22052006 · Pull Request #3785 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: [v1.x] Resolve a failed SSE message POST instead of hanging the caller by Mart22052006 · Pull Request #3785 · modelcontextprotocol/python-sdk

X Title: [v1.x] Resolve a failed SSE message POST instead of hanging the caller by Mart22052006 · Pull Request #3785 · modelcontextprotocol/python-sdk

Description: Fixes #2110 (the SSE part, on v1.x; #3278 covers main) Backports the SSE half of #3278 to v1.x: a failed message POST now resolves its request with a JSON-RPC error instead of leaving the caller hanging. Motivation and Context sse_client's post_writer called raise_for_status() on every message POST and swallowed the error in a catch-all. A request whose POST failed (a 429 from a rate limiter, a 401, a refused connection) was never resolved: its caller waited for its own timeout, or forever without one. The write loop died with it, so every later message was dropped. We hit this in production: a 429 from a rate limiter in front of an MCP server left an agent's tool call waiting 90 minutes for an unrelated outer timeout. How Has This Been Tested? 10 new tests in tests/shared/test_sse.py, all of which fail on unpatched v1.x (7 hang, 3 end with a closed stream or the wrong error): non-2xx answers (302, 401, 429, 500) and a refused connection reach the caller, and the session keeps working; a 404 maps to "Session terminated" only while the endpoint carries a session id; a failed notification is only logged; a server request answered while a request's POST is failing (the test times out if the error is delivered inline); a failure whose error can no longer be delivered, after the SSE stream ended, is contained. The full suite passes with 100% coverage, along with pyright and ruff. The SSE tests also pass on 3.10 with lowest-direct deps and on 3.14. Breaking Changes None. A caller that used to hang now gets an McpError, and later messages keep flowing. Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer): asked on #2110 I have disclosed any AI assistance and can explain the change in my own words I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context The outcomes match #3278 on main: a non-2xx status gives INTERNAL_ERROR "Server returned an error response", or INVALID_REQUEST "Session terminated" for a 404 while the endpoint carries a session id; an error before any response gives CONNECTION_CLOSED "Failed to send message: …". One v1.x-specific difference: the error is delivered from a task of its own. v1.x ClientSession answers server requests inline in its receive loop, so a reply can be waiting on the write stream just as the error needs the receive loop, and delivering it from the write loop deadlocks. AI assistance: written with Claude Code, as the commit's Co-Authored-By trailer notes.

Open Graph Description: Fixes #2110 (the SSE part, on v1.x; #3278 covers main) Backports the SSE half of #3278 to v1.x: a failed message POST now resolves its request with a JSON-RPC error instead of leaving the caller ha...

X Description: Fixes #2110 (the SSE part, on v1.x; #3278 covers main) Backports the SSE half of #3278 to v1.x: a failed message POST now resolves its request with a JSON-RPC error instead of leaving the caller ha...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3785

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ad837a1c-e50b-707e-d274-6e2f03b3a284
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD4C8:96DDF:146DF0A:19E1EE7:6B01268D
html-safe-noncedc87f333856de5dd340778cdc172f8815e018488e2988df99f63faf896ecaef5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEM4Ojk2RERGOjE0NkRGMEE6MTlFMUVFNzo2QjAxMjY4RCIsInZpc2l0b3JfaWQiOiI2NTY2MjEwOTEzNzYwNzgxOTY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac0b8f5b18ef864704819763ec4cb0218eb6ff55f7656aeb38fa485469c4cf4f63
hovercard-subject-tagpull_request:5059293748
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3785/files
twitter:imagehttps://avatars.githubusercontent.com/u/157504417?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/157504417?s=400&v=4
og:image:altFixes #2110 (the SSE part, on v1.x; #3278 covers main) Backports the SSE half of #3278 to v1.x: a failed message POST now resolves its request with a JSON-RPC error instead of leaving the caller ha...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3785%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3785%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues310 (310)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
Mart22052006https://github.com/Mart22052006
modelcontextprotocol:v1.xhttps://github.com/modelcontextprotocol/python-sdk/tree/v1.x
Mart22052006:fix/v1.x-sse-post-errorhttps://github.com/Mart22052006/python-sdk/tree/fix/v1.x-sse-post-error
Conversation 1 https://github.com/modelcontextprotocol/python-sdk/pull/3785
Commits 1 https://github.com/modelcontextprotocol/python-sdk/pull/3785/commits
Checks 37 https://github.com/modelcontextprotocol/python-sdk/pull/3785/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/3785/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
[v1.x] Resolve a failed SSE message POST instead of hanging the caller https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#top
Show all changes 1 commit https://github.com/modelcontextprotocol/python-sdk/pull/3785/files
013c969 [v1.x] Resolve a failed SSE message POST instead of hanging the caller Mart22052006 Oct 28, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3785/commits/013c969f48df6cfca21172cb8ad3826af953dc75
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3785/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
sse.py https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
test_sse.py https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
src/mcp/client/sse.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
View file https://github.com/Mart22052006/python-sdk/blob/013c969f48df6cfca21172cb8ad3826af953dc75/src/mcp/client/sse.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3785/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
tests/shared/test_sse.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
View file https://github.com/Mart22052006/python-sdk/blob/013c969f48df6cfca21172cb8ad3826af953dc75/tests/shared/test_sse.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3785/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/3785/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3785/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.