Skip to content

fix: suppress ClosedResourceError tracebacks in streamable HTTP transport#22

Merged
elijahgjacob merged 1 commit intomainfrom
fix/suppress-sdk-session-crash-logs
Mar 12, 2026
Merged

fix: suppress ClosedResourceError tracebacks in streamable HTTP transport#22
elijahgjacob merged 1 commit intomainfrom
fix/suppress-sdk-session-crash-logs

Conversation

@elijahgjacob
Copy link
Copy Markdown
Collaborator

Summary

  • Suppresses noisy ClosedResourceError tracebacks from the MCP SDK's streamable HTTP session manager
  • These fire when a client disconnects mid-request (timeout, network drop, Cursor closing connection)
  • Harmless in stateless_http=True mode — each session is isolated, the server self-heals — but the full ExceptionGroup traceback clutters deploy logs
  • Sets mcp.server.streamable_http_manager logger to CRITICAL as a targeted suppression

Root cause

Known bug in mcp Python SDK v1.26.0. The error handler tries to send a log message back to an already-closed write stream, causing an unhandled anyio.ClosedResourceError. Upstream fix: python-sdk PR #2072.

What this does NOT fix

  • The underlying race condition (that's an SDK fix)
  • Uvicorn graceful shutdown timeout messages during Railway redeploys (benign, 0 tasks affected)

Test plan

  • 61 unit tests pass
  • 22 smoke tests pass against local Docker
  • Verified server starts and responds to MCP requests normally
  • Change is a single-line logger level override — no functional behavior change

Made with Cursor

…port

Adjusted logging level for the MCP SDK's streamable HTTP manager to CRITICAL to reduce noise from harmless ClosedResourceError tracebacks when clients disconnect mid-request. This change addresses an issue in stateless mode and aligns with an upstream fix in python-sdk PR #2072.
@elijahgjacob elijahgjacob merged commit 08e16bc into main Mar 12, 2026
2 checks passed
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