Skip to content

Commit

Permalink
[lib] Don't swallow errors in useGetAndUpdateDeviceListsForUsers
Browse files Browse the repository at this point in the history
Summary:
https://linear.app/comm/issue/ENG-9730/native-crashes-when-call-to-identity-fails

Depends on D13863

Test Plan:
Force the error when sending message:

1. Create DM with some user
2. Change identity address to some random address
3. Remove device lists by dispatching an action as described in the issue
4. Try to send a message
5. Verify that the app doesn't crash and user can retry sending the message and you can see the error nicely in the logs

Reviewers: tomek, kamil

Reviewed By: kamil

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D13864
  • Loading branch information
graszka22 committed Nov 6, 2024
1 parent 90e9198 commit 3f50d08
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/hooks/peer-list-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,10 @@ function useGetAndUpdateDeviceListsForUsers(): (

return React.useCallback(
async (userIDs: $ReadOnlyArray<string>, broadcastUpdates: ?boolean) => {
let result;
try {
result = await Promise.race([
getDeviceListsForUsers(userIDs),
throwOnTimeout(userIDs),
]);
} catch (e) {
console.log(e);
}

const result = await Promise.race([
getDeviceListsForUsers(userIDs),
throwOnTimeout(userIDs),
]);
if (!result) {
return null;
}
Expand Down

0 comments on commit 3f50d08

Please sign in to comment.