File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -430,9 +430,22 @@ async def _handle_sse_response(
430430 logger .debug (f"SSE stream ended: { e } " )
431431
432432 # Stream ended without response - reconnect if we received an event with ID
433- if last_event_id is not None : # pragma: no branch
433+ if last_event_id is not None :
434434 logger .info ("SSE stream disconnected, reconnecting..." )
435435 await self ._handle_reconnection (ctx , last_event_id , retry_interval_ms )
436+ else :
437+ error_response = JSONRPCError (
438+ jsonrpc = "2.0" ,
439+ id = ctx .session_message .message .root .id
440+ if isinstance (ctx .session_message .message .root , JSONRPCRequest )
441+ else "Unknown" ,
442+ error = ErrorData (
443+ code = - 32000 ,
444+ message = "SSE stream disconnected without response (read timeout or server closed connection)" ,
445+ ),
446+ )
447+ error_message = JSONRPCMessage (root = error_response )
448+ await ctx .read_stream_writer .send (SessionMessage (error_message ))
436449
437450 async def _handle_reconnection (
438451 self ,
You can’t perform that action at this time.
0 commit comments