matrix-org / matrix-org/matrix-js-sdk

getExtendedProfileProperty() can return stale profile entries as it uses a cache without a TTL

Open
#5,402 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-Technical-Debt O-Frequent S-Minor T-Defect
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.