Skip to content

fix(everything): clean up subscriptions on session disconnect - #4712

Open
arimu1 wants to merge 1 commit into
modelcontextprotocol:mainfrom
arimu1:fix-4710-everything-cleanup-subscriptions
Open

fix(everything): clean up subscriptions on session disconnect#4712
arimu1 wants to merge 1 commit into
modelcontextprotocol:mainfrom
arimu1:fix-4710-everything-cleanup-subscriptions

Conversation

@arimu1

@arimu1 arimu1 commented Aug 29, 2026

Copy link
Copy Markdown

Summary

  • Add removeSubscriber(sessionId) in src/everything/resources/subscriptions.ts to remove a disconnected session from every URI subscriber set and drop empty map entries.
  • Call removeSubscriber(sessionId) from the server factory cleanup() alongside the existing logging, resource-update interval, and task-store teardown.
  • Add unit tests verifying disconnected sessions stop receiving simulated resource updates and that other sessions remain subscribed.

Fixes #4710

Test plan

  • npx vitest run __tests__/resources.test.ts __tests__/server.test.ts — 31/31 passing
  • npm run build — clean TypeScript compile

Export removeSubscriber() to drop a session from all URI subscriber sets
when a transport session closes, and call it from cleanup() alongside
the existing interval and logging teardown.

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