everything: remove disconnected sessions from resource subscriptions - #4711
Closed
vishalhabib99 wants to merge 1 commit into
Closed
everything: remove disconnected sessions from resource subscriptions#4711vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit 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 #4710
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4710.
subscriptions(Map<uri, Set<sessionId>>insrc/everything/resources/subscriptions.ts) 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 —cleanup(sessionId)stops the logging/update intervals and task-store timers but never touchedsubscriptions.Fix: add
removeSubscriber(sessionId), which iterates the map, deletes the session from eachSet, and drops any URI entry left with no subscribers. Call it fromcleanup()alongside the existing calls, matching the pattern the reporter suggested in the issue.Verified:
tsc --noEmit— cleanvitest run __tests__/resources.test.ts __tests__/server.test.ts— 29/29 passingprettier --check— passesImpact is limited to the reference
everythingserver, but per the issue, it's the example people copy, so worth fixing correctly.