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 @@ -399,7 +399,10 @@ impl ServerRuntime {
399399 let transport = self . transport_by_stream ( stream_id) . await ?;
400400
401401 let ( disconnect_tx, mut disconnect_rx) = oneshot:: channel :: < ( ) > ( ) ;
402- let _ = transport. keep_alive ( ping_interval, disconnect_tx) . await ;
402+ let abort_alive_task = transport
403+ . keep_alive ( ping_interval, disconnect_tx)
404+ . await ?
405+ . abort_handle ( ) ;
403406
404407 // in case there is a payload, we consume it by transport to get processed
405408 if let Some ( payload) = payload {
@@ -436,11 +439,13 @@ impl ServerRuntime {
436439 }
437440 // close the stream after all messages are sent, unless it is a standalone stream
438441 if !stream_id. eq( DEFAULT_STREAM_ID ) {
442+ abort_alive_task. abort( ) ;
439443 return Ok ( ( ) ) ;
440444 }
441445 }
442446 _ = & mut disconnect_rx => {
443447 self . remove_transport( stream_id) . await ?;
448+ abort_alive_task. abort( ) ;
444449 // Disconnection detected by keep-alive task
445450 return Err ( SdkError :: connection_closed( ) . into( ) ) ;
446451
You can’t perform that action at this time.
0 commit comments