We want to make sure UserInfosHandler doesn't query for a single user's avatar from the keyserver more than once per app start. We accomplish this by maintaining a set of user IDs for which we've requested avatars
Details
Details
Logged the contents of userIDsWithoutOwnID without this change and saw the same user IDs appearing repeatedly. After this change, user IDs only appeared once in the logs
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Branch
- userinfoshandler
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
lib/handlers/user-infos-handler.react.js | ||
---|---|---|
98–99 | I'd do it in one pass but doesn't really matter | |
109–112 | I've noticed an issue with this sort of caching strategy where an initial timeout can cause the fetch to fail under the user kills & restarts the app Could be addressed this way: const updateRelationshipsPromise = (async () => { try { return await callUpdateRelationships({ action: relationshipActions.ACKNOWLEDGE, userIDs: userIDsWithoutOwnID, }); } catch (e) { if (e instanceof FetchTimeout) { userIDsWithoutOwnID.forEach(id => requestedAvatarsRef.current.delete(id)); } throw e; } })(); void dispatchActionPromise( updateRelationshipsActionTypes, updateRelationshipsPromise, ); (Not sure if it should be FetchTimeout or SocketTimeout – please test to make sure it works.) |
lib/handlers/user-infos-handler.react.js | ||
---|---|---|
109–112 | It was indeed FetchTimeout. I reduced the timeout for the update_relationships keyserver call to 10ms and was able to reach the if condition in the catch block |