Skip to content

everything: remove disconnected sessions from resource subscriptions - #4716

Open
vishalhabib99 wants to merge 1 commit into
modelcontextprotocol:mainfrom
vishalhabib99:fix/everything-subscription-cleanup
Open

everything: remove disconnected sessions from resource subscriptions#4716
vishalhabib99 wants to merge 1 commit into
modelcontextprotocol:mainfrom
vishalhabib99:fix/everything-subscription-cleanup

Conversation

@vishalhabib99

Copy link
Copy Markdown

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.

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 from cleanup().

Fixes #4710

(Re-opened as a fresh PR — the original #4711 was closed automatically when my fork was deleted; same fix, no changes.)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

everything: subscriptions map never drops a disconnected session

1 participant