Skip to content

fix: free cap slot on disconnect, not just on room GC#13

Merged
tim4724 merged 1 commit into
mainfrom
fix/free-cap-on-disconnect
May 10, 2026
Merged

fix: free cap slot on disconnect, not just on room GC#13
tim4724 merged 1 commit into
mainfrom
fix/free-cap-on-disconnect

Conversation

@tim4724
Copy link
Copy Markdown
Owner

@tim4724 tim4724 commented May 10, 2026

Summary

  • Admission counted members.length (allocated, monotonic) instead of room.active (live), so once a full room lost a client the cap stayed wedged until the room emptied entirely.
  • New joiners always push to the next index, so an index can now exceed maxClients in long-lived rooms with churn — that's intentional and documented.
  • Reclaim path also checks the cap: a returning clientId may find someone took the spot. First-come-first-served, no priority for prior owners.

Test plan

  • Existing 64 tests still green
  • New: 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 room
  • New: reclaim fails when room re-filled while disconnected — asserts Room is full when original returns after a stranger took the spot
  • Flipped the prior new clientId cannot consume a disconnected owned slot test — that one was pinning the bug

🤖 Generated with Claude Code

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>
@tim4724 tim4724 merged commit 1e33985 into main May 10, 2026
2 checks passed
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.

1 participant