streamable-http server: stateful session workers ignore config.cancellation_token and stay alive until keep_alive after shutdown
Maintainer antworten meist innerhalb von 3 Tagen
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
We run one StreamableHttpService per agent run: rmcp 3.7.0 with server and transport-streamable-http-server, LocalSessionManager::default(), and the default config plus with_cancellation_token(...). It sits behind axum::serve(...).with_graceful_shutdown(...). The client is a child process. When the run ends we kill it, cancel the token and wait for the server task. The client never sends DELETE.
The stateful session created by its initialize keeps running after that. In one trace the last tools/call response went out at 00:16:43.820 and our handler was dropped at 00:21:43.823. That is SessionConfig::DEFAULT_KEEP_ALIVE (300 s) after the last event the session worker handled. The worker task owns the handler, so whatever the handler holds lives that long too. For us that kept a per-run resource alive and held up teardown for five minutes.
Reading the code (the same paths are still on main):
StreamableHttpService::spawn_session_workerintower.rsis a plaintokio::spawn. Itsserve_servercall creates its ownCancellationToken.LocalSessionManager::create_sessionusesWorkerTransport::spawn(worker), which also starts from a fresh token. As far as I can tell,config.cancellation_tokenonly reaches the SSE response streams and the stateless path.- The worker task keeps an
Arcof the session manager, and the manager keeps theLocalSessionHandleand itsevent_tx. So dropping the service or router doesn't close the worker'sevent_rxeither. Only DELETE,close_sessionor the idle timeout end the session.
The doc comment on StreamableHttpServerConfig::cancellation_token says cancelling it terminates all active sessions, so either the docs or the behaviour is off.
Is the token meant to end stateful sessions as well? If so, passing a child of config.cancellation_token into the worker looks like it would fix this, either through WorkerTransport::spawn_with_ct in create_session or by racing it in spawn_session_worker. A way to close every session from the service or the manager on shutdown would work for us too.
For now we keep the Arc<LocalSessionManager>, call close_session for every entry in sessions once the server task has finished, and keep run-scoped state out of the handler.
Possibly related: #1325 (in-flight calls are not cancelled on disconnect in the session-manager path) and #857.
- Vorherrschende Sprache
- Rust
- Sterne
- 4.1k
- Forks
- 694
- Ø Merge
- 4 T. 9 Std.
- Gemergte PRs (30 T.)
- 41
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/rust-sdk
-
Support tool exposure modes (direct / deferred / codemode) and client-side aggregation.Evtl. vergeben @jamadeo hat das heute übernommen. Offenenhancement P3 T-model T-service
modelcontextprotocol/rust-sdk#1437 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Return MergedList<T> from list_all_* and drop the _with_cache_hint variantsEvtl. vergeben @DaleSeo hat das vor 4 Tagen übernommen. Offenenhancement P3 ready for work T-service v4
modelcontextprotocol/rust-sdk#1430 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Server logs a fabricated 'initialize' (with synthesized rmcp/3.8.0 peer identity) for no-initialize SEP-2567 requests, ignoring clientInfo from _metaEvtl. vergeben @jamadeo hat das vor 4 Tagen übernommen. Offenbug P2 ready for work T-service T-transport
modelcontextprotocol/rust-sdk#1425 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
OAuth discovery drops explicit default ports from advertised issuer identifiersEvtl. vergeben @gocamille hat das vor 6 Tagen übernommen. Offenbug P1 ready for work T-security T-transport
modelcontextprotocol/rust-sdk#1420 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
`register_client` drops `client_secret_expires_at` from the registration responseEvtl. vergeben @gocamille hat das vor 7 Tagen übernommen. Offenbug P2 ready for work T-security
modelcontextprotocol/rust-sdk#1416 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in modelcontextprotocol/rust-sdk
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
pop-os/cosmic-applets#1619 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
binding:python bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
coollabsio/orbit#72 ·
Maintainer antworten meist innerhalb von 1 Tag
-
swc_common: Mark::least_ancestor never returns when the answer is the root mark (ANT-2026-JYDQGGRT)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
swc-project/swc-ai-issues#137 ·
-
Synth suite fails unless run from the repo root: signal_flow's default machine path is cwd-relativeOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
Nimblesite/osprey#370 ·
Maintainer antworten meist innerhalb von 1 Tag