Closed
Description
Describe the bug
When running pytest on codespaces tests/shared/test_streamable_http.py::test_streamablehttp_client_resumption occaisionally hangs
To Reproduce
Steps to reproduce the behavior:
- Go to main branch of code
- Open branch in fresh codespace
- In codespace terminal install uv - e.g. curl -LsSf https://astral.sh/uv/install.sh | sh
- In codespace terminal install dev dependencies e.g. uv sync --frozen --all-extras --dev
- In codespace terminal run
uv run pytest -vv - In codespace terminal check tests completed
- Repeat 5 until test hangs (usually within 1-5 repeats but I have seen up to 10 successes prior to a hang)
Expected behavior
Tests run to completion and do not hang
Screenshots
Desktop (please complete the following information):
- OS: Github codeworkspace
- Browser Firefox
- Version main
Additional context
As can be seen from the screen shot their appears to be a port open, I suspect a race condition meaning the test some times gets stuck, I've not yet had a chance to figure out what the test is doing
Reacted by Dalibor Petras
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
davemssavage commentedon May 18, 2025
doing some checks with print statements indicates the hang is here:
https://github.com/modelcontextprotocol/python-sdk/blob/main/tests/shared/test_streamable_http.py#L1126
then
https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py#L280
On the receiving side it seems to get to here:
https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/client/streamable_http.py#L232
Which just blocks waiting for event_source.aiter_sse() to yield an sse event but nothing arrives
This may be a simple deadlock where each side is waiting for the other to send a message
davemssavage commentedon May 18, 2025
Noting also that this might be a known issue on the httpx-sse library:
florimondmanca/httpx-sse#4
Further digging and encode/httpx#2186 (comment) seems to suggest a hacky fix
davemssavage commentedon Jul 11, 2025
I've not observed this in a while and the tests have been updated so closing this assuming it has been fixed