Skip to content

fix: surface stateful HTTP session crash cause#2742

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/stateful-http-crash-cause
Open

fix: surface stateful HTTP session crash cause#2742
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/stateful-http-crash-cause

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • surface the original stateful session app.run() exception when a POST fails after the session stream closes
  • clean up the per-request memory stream on that failure path
  • avoid a secondary ClosedResourceError when reporting the failure back to an already closed writer

Fixes #2741.

To verify

  • python -m pytest tests\server\test_streamable_http_manager.py -q
  • python -m ruff check src\mcp\server\streamable_http.py src\mcp\server\streamable_http_manager.py tests\server\test_streamable_http_manager.py
  • python -m ruff format --check src\mcp\server\streamable_http.py src\mcp\server\streamable_http_manager.py tests\server\test_streamable_http_manager.py
  • git diff --check -- src\mcp\server\streamable_http.py src\mcp\server\streamable_http_manager.py tests\server\test_streamable_http_manager.py

@he-yufeng he-yufeng force-pushed the fix/stateful-http-crash-cause branch 5 times, most recently from 426e7ed to 66487ae Compare June 1, 2026 01:10
@he-yufeng he-yufeng force-pushed the fix/stateful-http-crash-cause branch from 66487ae to 08bbc28 Compare June 1, 2026 01:17
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.

Stateful Streamable HTTP: in-session exceptions are masked as an empty -32603; real cause only in a separate "Session crashed" log

1 participant