You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the /messages endpoint returns say 404 or 405, a client hangs rather than raise the exception I would expect.
I get the error summary printed:
Error in post_writer: Client error '404 Not Found' for url 'http://localhost:8000/wrong?sessionId=d9e6a07d-e96f-420a-99f0-90f5444ddd43'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
Then nothing until I ctrl+c, when I get the traceback:
Traceback
^CTraceback (most recent call last):
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/anyio/streams/memory.py", line 111, in receive
return self.receive_nowait()
^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/anyio/streams/memory.py", line 106, in receive_nowait
raise WouldBlock
anyio.WouldBlock
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/samuel/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/samuel/code/pydantic-ai/mcp_client_error.py", line 13, in run
async with ClientSession(read, write) as session:
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/mcp/shared/session.py", line 210, in __aexit__
return await self._task_group.__aexit__(exc_type, exc_val, exc_tb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 776, in __aexit__
raise exc_val
File "/Users/samuel/code/pydantic-ai/mcp_client_error.py", line 14, in run
await session.initialize()
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/mcp/client/session.py", line 122, in initialize
result = await self.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/mcp/shared/session.py", line 252, in send_request
response_or_error = await response_stream_reader.receive()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/anyio/streams/memory.py", line 119, in receive
await receive_event.wait()
File "/Users/samuel/Library/Caches/uv/environments-v2/mcp-client-error-5fc93589004e4f10/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1774, in wait
await self._event.wait()
File "/Users/samuel/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/asyncio/locks.py", line 212, in wait
await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/samuel/code/pydantic-ai/mcp_client_error.py", line 26, in <module>
asyncio.run(run())
File "/Users/samuel/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/samuel/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 123, in run
raise KeyboardInterrupt()
KeyboardInterrupt
I also experienced this hang for a similar but different reason. When the sse_client context manager raises the exception in line 81, the code will hang when you get to line 107 of sse_client (send call).
I suspect it's because there is nothing consuming the data we send yet. Of course nothing could be consuming the read_stream because we haven't yielded it yet since the above failure comes during startup.
Uh oh!
There was an error while loading. Please reload this page.
When the
/messages
endpoint returns say 404 or 405, a client hangs rather than raise the exception I would expect.I get the error summary printed:
Then nothing until I ctrl+c, when I get the traceback:
Traceback
MRE code:
Client:
Server
The text was updated successfully, but these errors were encountered: