| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…equests This fix ensures that ClientSession.request() does not hang indefinitely when the underlying SSE transport encounters a timeout or other fatal exception before the RPC response is received. It propagates the exception to all in-flight request streams, waking up waiters immediately.
There was a problem hiding this comment.
This PR targets issue #1401 by ensuring that transport-level exceptions (e.g., SSE read timeouts) don’t leave in-flight RPC calls hanging: when the read stream surfaces an Exception, the session should wake/fail all pending request waiters.
Changes:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
|
|
||
| # Fix #1401: Propagate exception to all pending requests | ||
| # This prevents waiters from hanging when the transport fails | ||
| error_data = ( | ||
| message.to_error_data() | ||
| if isinstance(message, MCPError) | ||
| else ErrorData(code=0, message=str(message)) | ||
| ) | ||
| jsonrpc_error = JSONRPCError(jsonrpc="2.0", id=None, error=error_data) # id=None because it applies to all | ||
|
|
||
| # We must send an error to every individual waiter | ||
| for req_id, stream in list(self._response_streams.items()): | ||
| # Send a response with the correct ID | ||
| await stream.send(JSONRPCError(jsonrpc="2.0", id=req_id, error=error_data)) | ||
|
|
|
|
||
| # Fix #1401: Propagate exception to all pending requests | ||
| # This prevents waiters from hanging when the transport fails | ||
| error_data = ( | ||
| message.to_error_data() | ||
| if isinstance(message, MCPError) | ||
| else ErrorData(code=0, message=str(message)) | ||
| ) | ||
| jsonrpc_error = JSONRPCError(jsonrpc="2.0", id=None, error=error_data) # id=None because it applies to all | ||
|
|
||
| # We must send an error to every individual waiter | ||
| for req_id, stream in list(self._response_streams.items()): | ||
| # Send a response with the correct ID | ||
| await stream.send(JSONRPCError(jsonrpc="2.0", id=req_id, error=error_data)) | ||
|
|
| message.to_error_data() | ||
| if isinstance(message, MCPError) | ||
| else ErrorData(code=0, message=str(message)) | ||
| ) | ||
| jsonrpc_error = JSONRPCError(jsonrpc="2.0", id=None, error=error_data) # id=None because it applies to all | ||
|
|
||
| # We must send an error to every individual waiter | ||
| for req_id, stream in list(self._response_streams.items()): | ||
| # Send a response with the correct ID | ||
| await stream.send(JSONRPCError(jsonrpc="2.0", id=req_id, error=error_data)) | ||
|
|
|
|
||
| # Fix #1401: Propagate exception to all pending requests | ||
| # This prevents waiters from hanging when the transport fails | ||
| error_data = ( | ||
| message.to_error_data() | ||
| if isinstance(message, MCPError) | ||
| else ErrorData(code=0, message=str(message)) | ||
| ) | ||
| jsonrpc_error = JSONRPCError(jsonrpc="2.0", id=None, error=error_data) # id=None because it applies to all | ||
|
|
||
| # We must send an error to every individual waiter | ||
| for req_id, stream in list(self._response_streams.items()): | ||
| # Send a response with the correct ID | ||
| await stream.send(JSONRPCError(jsonrpc="2.0", id=req_id, error=error_data)) | ||
|
|
||
| continue | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Fixed SSE timeout hang in BaseSession._receive_loop. This fix propagates transport-level exceptions (like SSE read timeouts) to all pending request streams, ensuring RPC calls don't hang if the underlying connection fails. This specifically addresses issue #1401.