Skip to content

everything: subscriptions map never drops a disconnected session #4710

Description

@olaservo

In src/everything/resources/subscriptions.ts, subscriptions is a module-level Map<uri, Set<sessionId>>. A session id is added on resources/subscribe and removed only on resources/unsubscribe. Nothing removes it when the session ends.

Both transports call cleanup(sessionId) from server.server.onclose (transports/streamableHttp.ts, transports/sse.ts). That function (server/index.ts:109) calls stopSimulatedLogging, stopSimulatedResourceUpdates and taskStore.cleanup(), so the interval timers are cleared, but subscriptions is not touched. A client that subscribes and then disconnects without unsubscribing leaves its session id in every Set it joined, for the life of the process.

Until #4104 the else branch of sendSimulatedResourceUpdates carried a comment saying it removed disconnected subscribers. It did not (it deleted from a Set that provably lacked the element), and the branch is now gone, so there is no longer anything that even implies cleanup exists.

Impact is small for a reference server, but it is the example people copy. Suggested fix: export a removeSubscriber(sessionId) from subscriptions.ts that iterates the map, deletes the session from each Set and drops empty entries, and call it from cleanup().

Metadata

Metadata

Assignees

No one assigned

    Labels

    server-everythingReference implementation for the Everything MCP server - src/everything

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions