Skip to content

Commit 58aca04

Browse files
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6b85e59 commit 58aca04

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/mcp/shared/session.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,17 +432,16 @@ async def _handle_session_message(message: SessionMessage) -> None:
432432
# Fix #1401: Propagate exception to all pending requests
433433
# This prevents waiters from hanging when the transport fails
434434
error_data = (
435-
message.to_error_data()
436-
if isinstance(message, MCPError)
435+
message.to_error_data()
436+
if isinstance(message, MCPError)
437437
else ErrorData(code=0, message=str(message))
438438
)
439-
jsonrpc_error = JSONRPCError(jsonrpc="2.0", id=None, error=error_data) # id=None because it applies to all
440-
439+
441440
# We must send an error to every individual waiter
442441
for req_id, stream in list(self._response_streams.items()):
443442
# Send a response with the correct ID
444443
await stream.send(JSONRPCError(jsonrpc="2.0", id=req_id, error=error_data))
445-
444+
446445
continue
447446

448447
await _handle_session_message(message)

0 commit comments

Comments
 (0)