Skip to content

fix: suppress completed request cancellation leak#2611

Open
MukundaKatta wants to merge 1 commit into
modelcontextprotocol:mainfrom
MukundaKatta:codex/request-responder-cancel-leak
Open

fix: suppress completed request cancellation leak#2611
MukundaKatta wants to merge 1 commit into
modelcontextprotocol:mainfrom
MukundaKatta:codex/request-responder-cancel-leak

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

  • return the underlying CancelScope.exit suppression result from RequestResponder.exit
  • swallow a late cancellation from an already-cancelled/completed responder so cancelled requests do not tear down sibling tasks
  • add regressions for completed responder cancellations

Fixes #2610.

Tests

  • uv run pytest tests/shared/test_session.py -q -k "request_responder or request_cancellation"
  • uv run pytest tests/server/test_cancel_handling.py tests/shared/test_session.py -q
  • uv run ruff check src/mcp/shared/session.py tests/shared/test_session.py
  • uv run ruff format --check src/mcp/shared/session.py tests/shared/test_session.py
  • uv run pyright src/mcp/shared/session.py tests/shared/test_session.py

@MukundaKatta MukundaKatta force-pushed the codex/request-responder-cancel-leak branch from e7e92b3 to e199eef Compare May 15, 2026 20:10
@MukundaKatta MukundaKatta force-pushed the codex/request-responder-cancel-leak branch from e199eef to 274446f Compare May 15, 2026 20:13
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.

RequestResponder.__exit__ leaks CancelledError on cancelled request, killing the stdio receive loop

1 participant