Skip to content

Commit 1e6a108

Browse files
committed
test(server): register router streams under type-preserving keys
_request_stream_key prefixes string ids with s:, so bare "A"/"B" slots never receive responses and the unconsumed-stream sibling test timed out.
1 parent 47f7a39 commit 1e6a108

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/server/test_streamable_http_router.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
EventStore,
1414
StreamableHTTPServerTransport,
1515
StreamId,
16+
_request_stream_key,
1617
)
1718
from mcp.shared.message import SessionMessage
1819

@@ -56,11 +57,14 @@ async def test_router_unconsumed_request_stream_does_not_block_siblings() -> Non
5657
async with transport.connect() as (_read_stream, write_stream):
5758
# Model two concurrent POSTs at the point _handle_post_request has
5859
# registered the per-request stream but A's sse_writer has not yet
59-
# reached its first receive().
60-
streams["A"] = anyio.create_memory_object_stream[EventMessage](REQUEST_STREAM_BUFFER_SIZE)
61-
streams["B"] = anyio.create_memory_object_stream[EventMessage](REQUEST_STREAM_BUFFER_SIZE)
62-
a_send, a_recv = streams["A"]
63-
b_reader = streams["B"][1]
60+
# reached its first receive(). Routing keys must match `_request_stream_key`
61+
# (type-preserving prefixes), same as production registration.
62+
key_a = _request_stream_key("A")
63+
key_b = _request_stream_key("B")
64+
streams[key_a] = anyio.create_memory_object_stream[EventMessage](REQUEST_STREAM_BUFFER_SIZE)
65+
streams[key_b] = anyio.create_memory_object_stream[EventMessage](REQUEST_STREAM_BUFFER_SIZE)
66+
a_send, a_recv = streams[key_a]
67+
b_reader = streams[key_b][1]
6468
b_received = anyio.Event()
6569

6670
async def consume_b() -> None:

0 commit comments

Comments
 (0)