File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -400,17 +400,22 @@ async def post_writer(
400
400
sse_read_timeout = self .sse_read_timeout ,
401
401
)
402
402
403
- async def handle_request_async ():
404
- if is_resumption :
405
- await self ._handle_resumption_request (ctx )
406
- else :
407
- await self ._handle_post_request (ctx )
403
+ async def handle_request_async (ctx : RequestContext , is_resumption : bool ) -> None :
404
+ try :
405
+ if is_resumption :
406
+ await self ._handle_resumption_request (ctx )
407
+ else :
408
+ await self ._handle_post_request (ctx )
409
+ except Exception as e :
410
+ # Send error to read stream so client knows request failed
411
+ logger .error ("Request handler error: %s" , e )
412
+ await ctx .read_stream_writer .send (e )
408
413
409
414
# If this is a request, start a new task to handle it
410
415
if isinstance (message .root , JSONRPCRequest ):
411
- tg .start_soon (handle_request_async )
416
+ tg .start_soon (handle_request_async , ctx , is_resumption )
412
417
else :
413
- await handle_request_async ()
418
+ await handle_request_async (ctx , is_resumption )
414
419
415
420
except Exception :
416
421
logger .exception ("Error in post_writer" )
You can’t perform that action at this time.
0 commit comments