Skip to content

TeamService.addMembersToDefaultRooms resolves before default-room membership completes #38700

@Shreyas2004wagh

Description

@Shreyas2004wagh

Description:

TeamService.addMembersToDefaultRooms() is declared as async and is awaited by addMember(), but internally it iterates over default rooms using defaultRooms.map(async ...) without awaiting the resulting promises.

Because the async operations are not awaited, the function resolves before users are actually added to the team’s default rooms. Any rejection from addUserToRoom() is also not propagated back to the caller.

This creates a mismatch between the completion of the add-member operation and the actual team room membership state.

Steps to reproduce:

  1. Create or use a team that has default rooms configured.
  2. Add a user to the team via the API or UI.
  3. Immediately inspect the user’s room memberships or observe the UI.
  4. Notice the user may not yet be present in all default team rooms despite the operation reporting success.

Expected behavior:

Adding a user to a team should only complete once the user has been successfully added to all default team rooms.

Errors during default-room assignment should be surfaced so the add-member operation can fail or handle them appropriately.

Team membership should be immediately consistent after a successful add-member operation.

Actual behavior:

The add-member operation returns success before async default-room additions complete.

Failures inside addUserToRoom() are silently dropped.

Users may temporarily (or permanently, on failure) be missing from default team rooms after being added to a team.

Server Setup Information:

  • Version of Rocket.Chat Server: N/A (logic issue, reproducible via code inspection)

  • License Type: N/A

  • Number of Users: N/A

  • Operating System: N/A

  • Deployment Method: N/A

  • Number of Running Instances: N/A

  • DB Replicaset Oplog: N/A

  • NodeJS Version: N/A

  • MongoDB Version: N/A

Client Setup Information

  • Desktop App or Browser Version: N/A
  • Operating System: N/A

Additional context

Affected code is located in TeamService.addMembersToDefaultRooms, which is awaited by addMember().
The caller assumes completion semantics that are not currently enforced due to un-awaited async operations.

Relevant logs:

No specific server or browser logs are required to reproduce this issue.
The problem is observable through code inspection and by checking room membership immediately after adding a team member.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions