Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

fix: handle transport exceptions and ensure proper cleanup of in-flig…#1

Merged
EiffL merged 1 commit intomainEiffL/python-sdk:mainfrom
streamable_http_disconnectEiffL/python-sdk:streamable_http_disconnectCopy head branch name to clipboard
Aug 28, 2025
Merged

fix: handle transport exceptions and ensure proper cleanup of in-flig…#1
EiffL merged 1 commit intomainEiffL/python-sdk:mainfrom
streamable_http_disconnectEiffL/python-sdk:streamable_http_disconnectCopy head branch name to clipboard

Conversation

@EiffL
Copy link
Owner

@EiffL EiffL commented Aug 28, 2025

…ht requests
This pull request improves the robustness of the client-server communication by ensuring that transport-level disconnects are handled gracefully and do not leave requests hanging. It also adds a new test to verify that clients receive an appropriate error when the server goes down mid-request.

Transport error handling improvements:

  • In src/mcp/client/streamable_http.py, exceptions encountered while reading the SSE stream are now forwarded to the session read stream, which is then closed to signal that no further messages will arrive.
  • In src/mcp/shared/session.py, when a transport-level exception is received, it is forwarded to the incoming handler and all in-flight requests are failed with a CONNECTION_CLOSED error. The receive loop then exits, preventing clients from hanging indefinitely.

Testing enhancements:

  • Added an async test test_streamable_http_mid_call_disconnect in tests/shared/test_streamable_http.py to verify that a client receives a CONNECTION_CLOSED error if the server dies during a long-running tool call, rather than hanging.

@EiffL EiffL merged commit de6dd61 into main Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.