Fix /join <alias> command failing due to race condition
#31433
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #31005
There's a complex sequence of events that occurs when you type a join command.
joincommand works by dispatching anAction.ViewRoomaction with auto join set to true.RoomViewStore.viewRoomwhere the second if condition (else if (payload.room_alias)) runs and it resolves the room-alias to a room-id and via-server.viewRoomruns again, but now because room-id is present, the firstifblock runs.Somehow, the state doesn't include the room-alias or via_server so you end up trying to join just with the internal id and this obviously fails with a 404.
In the long term, we probably want to reduce the complexity of the RVS (or even remove it entirely).
But for now, we can explicitly pass the via_server through the join options.