File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
crates/rmcp/src/transport/streamable_http_server/session Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -328,11 +328,19 @@ impl LocalSessionWorker {
328328 if let Some ( http_request_id) = self . resource_router . remove ( resource) {
329329 tracing:: trace!( ?resource, http_request_id, "unregister resource" ) ;
330330 if let Some ( channel) = self . tx_router . get_mut ( & http_request_id) {
331- channel. resources . remove ( resource) ;
332- if channel. resources . is_empty ( ) {
331+ // It's okey to do so, since we don't handle batch json rpc request anymore
332+ // and this can be refactored after the batch request is removed in the coming version.
333+ if channel. resources . is_empty ( ) || matches ! ( resource, ResourceKey :: McpRequestId ( _) )
334+ {
333335 tracing:: debug!( http_request_id, "close http request wise channel" ) ;
334- self . tx_router . remove ( & http_request_id) ;
336+ if let Some ( channel) = self . tx_router . remove ( & http_request_id) {
337+ for resource in channel. resources {
338+ self . resource_router . remove ( & resource) ;
339+ }
340+ }
335341 }
342+ } else {
343+ tracing:: warn!( http_request_id, "http request wise channel not found" ) ;
336344 }
337345 }
338346 }
You can’t perform that action at this time.
0 commit comments