Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch when CryptoClient can't find room members #341

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AndrewFerr
Copy link
Contributor

CryptoClient#onRoomEvent may throw when looking up the members of a room with a client that isn't in the room, which can happen if appservice namespaces are broad & the appservice receives events for rooms that some of its managed clients are not members of.

Checklist

  • Tests written for all new code
    • Not adding a test for this until there are tests for appservice crypto.
  • Linter has been satisfied

CryptoClient#onRoomEvent may throw when looking up the members of a room
with a client that isn't in the room, which can happen if appservice
namespaces are broad & the appservice receives events for rooms that
some of its managed clients are not members of.
because:
- the failure will print its own logs
- the point of catching this is that it's _not_ an error
because the failure already logs the error
await this.engine.addTrackedUsers(members.map(e => e.membershipFor));
return this.client.getRoomMembers(roomId, null, ['join', 'invite']).then(
members => this.engine.addTrackedUsers(members.map(e => e.membershipFor)),
e => void LogService.warn("CryptoClient", `Unable to get members of room ${roomId}`),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we use a try/catch pattern here using async/await.

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