Skip to content

test_streamable_http.py::test_streamablehttp_client_resumption hangs intermittently #744

Closed

Description

@davemssavage

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:

  1. Go to main branch of code
  2. Open branch in fresh codespace
  3. In codespace terminal install uv - e.g. curl -LsSf https://astral.sh/uv/install.sh | sh
  4. In codespace terminal install dev dependencies e.g. uv sync --frozen --all-extras --dev
  5. In codespace terminal run uv run pytest -vv
  6. In codespace terminal check tests completed
  7. 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

Image

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

Activity

  1. davemssavage commented on May 18, 2025

    @davemssavage
    Author

    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

  2. davemssavage commented on May 18, 2025

    @davemssavage
    Author

    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

  3. davemssavage commented on Jul 11, 2025

    @davemssavage
    Author

    I've not observed this in a while and the tests have been updated so closing this assuming it has been fixed

  4. moved this from To triage to Done in 🐛 🛠on Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions