everything: remove disconnected sessions from resource subscriptions - #4716
everything: remove disconnected sessions from resource subscriptions#4716vishalhabib99 wants to merge 2 commits into
Conversation
subscriptions (Map<uri, Set<sessionId>>) only ever had entries removed via an explicit resources/unsubscribe call. A session that disconnects without unsubscribing stayed in every Set it had joined for the life of the process, since cleanup(sessionId) stopped logging/update intervals and task-store timers but never touched subscriptions. Add removeSubscriber(sessionId), which drops the session from every URI's subscriber set and removes any URI entry left with no subscribers, and call it from cleanup(). Fixes modelcontextprotocol#4710
Covers the fix for modelcontextprotocol#4710: a session removed via removeSubscriber no longer receives simulated resource-update notifications, and removing one session's subscription does not affect other sessions still subscribed to the same URI.
|
Pulled 8e2f0fe, 109 passing vs 107 on base ( Added two regression tests for |
|
Rebased onto latest main and CI is green (all Python/TypeScript build+test jobs passing). Added two regression tests for the Ready for review whenever you have a chance. |
subscriptions(Map<uri, Set<sessionId>>) only ever had entries removed via an explicitresources/unsubscribecall. A session that disconnects without unsubscribing stayed in everySetit had joined for the life of the process, sincecleanup(sessionId)stopped logging/update intervals and task-store timers but never touchedsubscriptions.Adds
removeSubscriber(sessionId), which drops the session from every URI's subscriber set and removes any URI entry left with no subscribers, and calls it fromcleanup().Fixes #4710
(Re-opened as a fresh PR — the original #4711 was closed automatically when my fork was deleted; same fix, no changes.)