@@ -282,9 +282,7 @@ impl<C: StreamableHttpClient> StreamableHttpClientWorker<C> {
282282
283283impl < C : StreamableHttpClient > StreamableHttpClientWorker < C > {
284284 /// Convert a raw SSE stream into a JSON-RPC message stream without
285- /// reconnection logic. Used for per-request POST SSE responses where
286- /// we close the stream after the first response and want the underlying
287- /// HTTP connection to be returned to the pool promptly.
285+ /// reconnection logic.
288286 fn raw_sse_to_jsonrpc (
289287 stream : BoxedSseStream ,
290288 ) -> impl Stream < Item = Result < ServerJsonRpcMessage , StreamableHttpError < C :: Error > > > + Send + ' static
@@ -347,11 +345,8 @@ impl<C: StreamableHttpClient> StreamableHttpClientWorker<C> {
347345 }
348346 if close_on_response && is_response {
349347 tracing:: debug!( "got response, draining sse stream for connection reuse" ) ;
350- // Drain remaining stream bytes so the HTTP/1.1 connection can
351- // be returned to the pool instead of being discarded. The
352- // server closes the channel shortly after sending the response,
353- // so this normally completes in microseconds on localhost. The
354- // timeout guards against servers that keep the stream open.
348+ // Consume the remaining stream so the HTTP/1.1 connection
349+ // returns to the pool cleanly.
355350 let _ = tokio:: time:: timeout ( std:: time:: Duration :: from_millis ( 50 ) , async {
356351 while sse_stream. next ( ) . await . is_some ( ) { }
357352 } )
@@ -788,10 +783,6 @@ impl<C: StreamableHttpClient> Worker for StreamableHttpClientWorker<C> {
788783 Ok ( ( ) )
789784 }
790785 Ok ( StreamableHttpPostResponse :: Sse ( stream, ..) ) => {
791- // Per-request POST SSE streams use a thin
792- // adapter instead of SseAutoReconnectStream so
793- // the stream ends immediately when the server
794- // closes the channel, enabling connection reuse.
795786 streams. spawn ( Self :: execute_sse_stream (
796787 Self :: raw_sse_to_jsonrpc ( stream) ,
797788 sse_worker_tx. clone ( ) ,
0 commit comments