Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 7, 2025

Addresses race condition in rejoin failure path where concurrent checks of pendingRooms could see stale state during cleanup.

Change

Add explicit this.pendingRooms.delete(id) before cleanupRoom() in the reject handler:

reject: (error: Error) => {
  console.error("Rejoin failed:", error);
  this.pendingRooms.delete(id);  // ← Added
  this.cleanupRoom(roomId, adaptor.crdtType);
  this.emitRoomStatus(id, RoomJoinStatus.Error);
},

While cleanupRoom() already deletes from pendingRooms internally, doing it first ensures proper ordering: any code checking pending state during cleanup will immediately see the room is no longer pending, preventing race conditions.

Matches pattern used in handleJoinError where explicit cleanup follows cleanupRoom.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ndler

Co-authored-by: zxch3n <18425020+zxch3n@users.noreply.github.com>
Copilot AI changed the title [WIP] Update join room implementation based on review feedback fix: add explicit pendingRooms cleanup before cleanupRoom in reject handler Dec 7, 2025
Copilot AI requested a review from zxch3n December 7, 2025 18:50
@zxch3n zxch3n marked this pull request as ready for review December 7, 2025 18:58
@zxch3n zxch3n merged commit 82c5480 into zxch3n/dynamic-auth-refresh Dec 7, 2025
@zxch3n zxch3n deleted the copilot/sub-pr-37 branch December 7, 2025 18:58
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.

2 participants