matrix-org / matrix-org/matrix-js-sdk
getExtendedProfileProperty() can return stale profile entries as it uses a cache without a TTL
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 704
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 40
Description
https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/client.ts#L7430 was recently changed to use a persistent cache for profile keys, as there is now the ability (via MSCXXXX) to sync profile changes from the homeserver. However there are a couple of catches:
- Not all keys from a profile are synced, but a filtered set.
- Not all homeserver implementations support federated profile change updates, so federated users will be stale.
getExtendedProfileProperty will also store the result of an explicit fetch from the homeserver in the cache, and will keep it there forever. Therefore over time the client will build up a set of forever cached properties if they rely on this function.
The solution is probably to either not cache the results, or cache with a TTL such that a profile can only be so many minutes behind. The cache exists to ensure that on restart the client doesn't hammer the homeserver with many requests, so there needs to be some thought put into when to expire the caches.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/client.ts around line 7430 and inspect how getExtendedProfileProperty stores fetched profile properties in the persistent cache. Review the cache behavior and profile-sync limitations, then define an expiration policy that bounds staleness while preserving the restart request reduction; done when explicitly fetched properties do not remain cached forever.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100