Uh oh!
There was an error while loading. Please reload this page.
Fix completed request cancellation cleanup - #2624
Open
FU-max-boop wants to merge 1 commit into
Open
Conversation
FU-max-boopforce-pushed
the
fix/request-responder-cancel-leak
branch
from
May 17, 2026 08:13
5db90d2 to
bb76886Compare
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
FU-max-boopforce-pushed
the
fix/request-responder-cancel-leak
branch
from
May 28, 2026 19:30
bb76886 to
edb78c0CompareFU-max-boop
commented
May 29, 2026
Author
CI note: I inspected the two failed Ubuntu jobs. They fail in existing tests that are not changed by this PR: Both pass locally on this branch: uv run --frozen --no-sync pytest tests/interaction/lowlevel/test_timeouts.py::test_session_level_timeout_applies_to_every_request -q
uv run --frozen --no-sync pytest tests/shared/test_streamable_http.py::test_client_crash_handled -qI do not have permission to rerun Actions on this repository, but these look like transient CI timing/port failures. Happy to patch if they reproduce consistently. |
mlorentedev added a commit
to mlorentedev/hive
that referenced
this pull request
Aug 8, 2026
Docs-only. `AGENTS.md` is the first file every agent reads in this repo, and its account of `src/hive/_compat.py` had drifted from the code on three points. All three were verified against the source and against the upstream trackers before writing. ## 1. Wrong patch target AGENTS.md said the shim patches `RequestResponder.__exit__` to swallow an anyio `CancelledError`. It patches **`RequestResponder.respond`**, to short-circuit the upstream `assert not self._completed`. The `__exit__` patch was **removed** — `_compat.py`'s own docstring records why: the issue-#75 symptom stopped reproducing on `mcp >= 1.27`, because `Server._handle_request` catches the in-flight cancellation before it can reach `__exit__`. ## 2. Wrong upstream tracker, and a stale instruction AGENTS.md pointed at [python-sdk#2610](modelcontextprotocol/python-sdk#2610) with an escalation deadline of 2026-06-12 and an instruction to port the fix ourselves. The shim's fate is actually tied to [**#2416**](modelcontextprotocol/python-sdk#2416) — open, maintainer-bot-confirmed on both `main` and `origin/v1.x`, with a contributor volunteering to fix it on 2026-07-11 (and our own reproduction already posted there on 2026-06-19). Meanwhile #2610 already has an open upstream fix PR, [#2624](modelcontextprotocol/python-sdk#2624). Porting it ourselves would duplicate existing work. **This matters beyond the docs:** #127 is scoped as "if #2610 is still silent, port the fix as our own upstream PR". That premise no longer holds. #127 is commented separately rather than being silently rescoped here. ## 3. Stale pin, and a guard that no longer holds AGENTS.md quoted `mcp>=1.26,<2.0`, with the rationale that a narrow cap stops a major `RequestResponder` refactor from silently breaking the shim. The actual constraint is now `mcp>=1.27,<3.0` (widened by #316). `<3.0` admits `mcp` 2.x — precisely the major boundary the cap existed to exclude. I recorded this as a **lost guard** rather than silently re-narrowing the pin: `apply()` degrades loudly (logs a warning and no-ops) rather than silently, so this is not a live bug, and re-narrowing a dependency range is a decision with its own consequences, not a docs edit. Flagging it for a deliberate call. ## Verification No code changed, so no test impact. The three claims were checked against `src/hive/_compat.py` (docstring + `apply()`), `pyproject.toml:49`, and the three upstream trackers via the GitHub API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CancelScope.__exit__only afterRequestResponderhas already completed and sent a responseFixes#2610.
Validation
uv run pytest tests/shared/test_session.py::test_request_cancellation tests/shared/test_session.py::test_completed_request_responder_suppresses_cancel_scope_exit tests/shared/test_session.py::test_incomplete_request_responder_propagates_cancel_scope_exit tests/server/test_cancel_handling.py -quv run ruff format --check src/mcp/shared/session.py tests/shared/test_session.pyuv run ruff check src/mcp/shared/session.py tests/shared/test_session.pyuv run pyright src/mcp/shared/session.py tests/shared/test_session.pygit diff --check