Skip to content

fix: reclaim empty rooms and cancel their cleanup intervals on disconnect#532

Open
xpoes123 wants to merge 1 commit into
qbreader:mainfrom
xpoes123:fix/room-interval-leak
Open

fix: reclaim empty rooms and cancel their cleanup intervals on disconnect#532
xpoes123 wants to merge 1 commit into
qbreader:mainfrom
xpoes123:fix/room-interval-leak

Conversation

@xpoes123

@xpoes123 xpoes123 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

User-created multiplayer rooms leaked two resources that were never reclaimed: the room entry in tossupBonusRooms persisted indefinitely after all players left, and the per-room setInterval for cleanupExpiredBansAndKicks ran for the life of the process with no way to stop it.

Problem

In ServerMultiplayerRoomMixin.js, the cleanup interval was started with no retained handle:

setInterval(this.cleanupExpiredBansAndKicks.bind(this), 5 * 60 * 1000);

And in handle-wss-connection.js, rooms were added to tossupBonusRooms but closeConnection never deleted them. Over time, both the map and the timer count grew without bound, and the room-list endpoints iterated a map full of empty, unreachable rooms.

Changes

  • Stores the interval handle as this.cleanupInterval so it can be cancelled.
  • In closeConnection, after leave, checks whether the room is now empty and idle (no tossup or bonus in progress). If so, and the room is neither permanent nor verified, calls clearInterval(this.cleanupInterval) and fires this.onEmpty?.().
  • In handle-wss-connection.js, wires onEmpty at creation time to delete tossupBonusRooms[roomName].
  • Imports BONUS_PROGRESS_ENUM (previously unused in this file) to support the idle check.

Risk & testing

Permanent and verified rooms are explicitly excluded from the reclaim path. Rooms with a question in progress are skipped (the idle guard); they will be reclaimed the next time they empty between questions. Rejoining a deleted room name creates a fresh room as before. semistandard and node --check pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xpoes123 xpoes123 changed the title fix: clean up empty rooms and per-room cleanup intervals fix: reclaim empty rooms and cancel their cleanup intervals on disconnect Jun 30, 2026
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