-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
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:
- Create or use a team that has default rooms configured.
- Add a user to the team via the API or UI.
- Immediately inspect the user’s room memberships or observe the UI.
- 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.