Title: Response leak in SSE handlers · Issue #1450 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Response leak in SSE handlers · Issue #1450 · modelcontextprotocol/python-sdk
X Title: Response leak in SSE handlers · Issue #1450 · modelcontextprotocol/python-sdk
Description: I found a resource leak in the streamable HTTP client. When SSE streaming fails with an exception, the HTTP response isn't closed. Location: src/mcp/client/streamable_http.py: _handle_sse_response (line 336) _handle_resumption_request (l...
Open Graph Description: I found a resource leak in the streamable HTTP client. When SSE streaming fails with an exception, the HTTP response isn't closed. Location: src/mcp/client/streamable_http.py: _handle_sse_response ...
X Description: I found a resource leak in the streamable HTTP client. When SSE streaming fails with an exception, the HTTP response isn't closed. Location: src/mcp/client/streamable_http.py: _handle_sse_respo...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1450
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Response leak in SSE handlers","articleBody":"I found a resource leak in the streamable HTTP client. When SSE streaming fails with an exception, the HTTP response isn't closed.\n\nLocation:\n`src/mcp/client/streamable_http.py`:\n- `_handle_sse_response` (line 336)\n- `_handle_resumption_request` (line 251)\n\nThe Issue:\npython\nasync def _handle_sse_response(self, response: httpx.Response, ...):\n try:\n event_source = EventSource(response)\n async for sse in event_source.aiter_sse():\n if is_complete:\n await response.aclose() # Only closed here\n break\n except Exception as e:\n await ctx.read_stream_writer.send(e)\n # response leaked!\n\nIf the SSE iteration raises an exception (malformed JSON, network error, etc.), the response is never closed.\n\nImpact:\nConnection pool gets exhausted in long-running clients, eventually causing new requests to hang or fail.\n\nFix:\ntry:\n ...\nexcept Exception as e:\n ...\nfinally:\n await response.aclose()\n\nBoth methods need this fix.\n\nEnv:\nPython SDK version: 1.1.2 (or main branch)\nPython: 3.12\nTransport: StreamableHTTP","author":{"url":"https://github.com/certainly-param","@type":"Person","name":"certainly-param"},"datePublished":"2025-10-09T07:11:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1450/python-sdk/issues/1450"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7867afc0-e173-41f5-93fb-21308dac140e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A046:1451F7:10E5241:18A5F92:6A608E1D |
| html-safe-nonce | 3313d5f5d56d253c52cec823eef1ba089e31dbb4d6e4bcc69d2b2ae1fd4bda1c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDQ2OjE0NTFGNzoxMEU1MjQxOjE4QTVGOTI6NkE2MDhFMUQiLCJ2aXNpdG9yX2lkIjoiNjA3NTAwNjMyNzQyNDMyMzEwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cb023269ebabe5cc4bcdf90ea7784b4137c44aa1fad26f992fd8545d47037c13 |
| hovercard-subject-tag | issue:3497915272 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/modelcontextprotocol/python-sdk/1450/issue_layout |
| twitter:image | https://opengraph.githubassets.com/820ce8c6b1ac8753624cbf8d4cdc39eaceb86f3c4f8b125c30eb60b559b5d4b3/modelcontextprotocol/python-sdk/issues/1450 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/820ce8c6b1ac8753624cbf8d4cdc39eaceb86f3c4f8b125c30eb60b559b5d4b3/modelcontextprotocol/python-sdk/issues/1450 |
| og:image:alt | I found a resource leak in the streamable HTTP client. When SSE streaming fails with an exception, the HTTP response isn't closed. Location: src/mcp/client/streamable_http.py: _handle_sse_response ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | certainly-param |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0632c7929f76e8db538ffed06ab2fc4c524a012b0888e95d96928690fcc604d |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4f9009410bd92637ba907f71dc7f7af3f0df45aa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width