Skip to content

fix(everything): cleanup subscriptions on session disconnect - #4715

Open
dlowzzxx wants to merge 1 commit into
modelcontextprotocol:mainfrom
dlowzzxx:fix/mcp-4710
Open

fix(everything): cleanup subscriptions on session disconnect#4715
dlowzzxx wants to merge 1 commit into
modelcontextprotocol:mainfrom
dlowzzxx:fix/mcp-4710

Conversation

@dlowzzxx

Copy link
Copy Markdown

Fixes #4710 — resources/subscribeadded tosubscriptionsmap butcleanup()never removed session on disconnect, leaking sessionIds. AddremoveSubscriber(sessionId)iterating map and deleting empty entries, called fromserver/index.ts:cleanup(). Verified with npm test (107 passed).

Fixes modelcontextprotocol#4710. The subscriptions Map retained sessionIds after
disconnect because cleanup() only cleared intervals and task store.
Export removeSubscriber(sessionId) that iterates the map, deletes the
session from each Set and drops empty entries, and call it from
server factory cleanup() (used by streamableHttp and sse onclose).

The reference server is the example clients copy; this prevents
unbounded growth from clients that subscribe then disconnect without
unsubscribing.
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