File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
crates/rust-mcp-sdk/src/mcp_runtimes Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -392,7 +392,10 @@ impl ServerRuntime {
392392 let transport = self . transport_by_stream ( stream_id) . await ?;
393393
394394 let ( disconnect_tx, mut disconnect_rx) = oneshot:: channel :: < ( ) > ( ) ;
395- let _ = transport. keep_alive ( ping_interval, disconnect_tx) . await ;
395+ let abort_alive_task = transport
396+ . keep_alive ( ping_interval, disconnect_tx)
397+ . await ?
398+ . abort_handle ( ) ;
396399
397400 // in case there is a payload, we consume it by transport to get processed
398401 if let Some ( payload) = payload {
@@ -429,11 +432,13 @@ impl ServerRuntime {
429432 }
430433 // close the stream after all messages are sent, unless it is a standalone stream
431434 if !stream_id. eq( DEFAULT_STREAM_ID ) {
435+ abort_alive_task. abort( ) ;
432436 return Ok ( ( ) ) ;
433437 }
434438 }
435439 _ = & mut disconnect_rx => {
436440 self . remove_transport( stream_id) . await ?;
441+ abort_alive_task. abort( ) ;
437442 // Disconnection detected by keep-alive task
438443 return Err ( SdkError :: connection_closed( ) . into( ) ) ;
439444
You can’t perform that action at this time.
0 commit comments