fix: free cap slot on disconnect, not just on room GC#13
Merged
Conversation
Admission used members.length (which only grows), so once a full room lost a client the cap was wedged until the room emptied entirely. Count room.active instead — disconnects free the spot, new joiners get the next index (which can exceed maxClients in churning rooms). Reclaim also checks the cap, since a freed spot may have been taken by the time the original clientId returns. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
members.length(allocated, monotonic) instead ofroom.active(live), so once a full room lost a client the cap stayed wedged until the room emptied entirely.maxClientsin long-lived rooms with churn — that's intentional and documented.clientIdmay find someone took the spot. First-come-first-served, no priority for prior owners.Test plan
disconnected slot frees the cap for a new joiner at the next index— asserts stranger gets index 2 (not 1) after guest disconnects in a 2-cap roomreclaim fails when room re-filled while disconnected— assertsRoom is fullwhen original returns after a stranger took the spotnew clientId cannot consume a disconnected owned slottest — that one was pinning the bug🤖 Generated with Claude Code