matrix-org / matrix-org/matrix-js-sdk
Device list tracking is broken when using "full" syncs (using memory store) causing UTD's
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 704
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 40
Description
This Issue was transferred over from EC:
https://github.com/element-hq/element-call/issues/2907
This is not anymore a specific EC issue because EC only used the memory store as a stop gap and now uses a IndexedDB based store.
This is still an issue in the js-sdk.
Original Description:
There seems to be a bit of a problem in the way we track other users' device lists.
matrix-sdk-crypto keeps a cache of other users' device lists, and relies on a notification in the device_lists section of the /sync response to let it know when a user has updated their devices (ie, that cache is stale). When we send an encrypted message to another user, we use that cache to know who to send it to.
That's ok as long as we keep doing incremental syncs. The problem is that Element Call, when it starts up, does a full /sync (ie, it doesn't pass a since parameter); in that case, the homeserver returns an empty device_lists response.
So, if another user has logged in on a new device while we were offline, we end up with a stale cache for that user's devices, and they will receive UTD messages from us.
This seems like something that needs to be fixed in matrix-js-sdk. Probably the easiest solution is to invalidate all device list caches on restart, if there is no saved sync token.
Note See also https://github.com/element-hq/element-call/issues/2907 for more details.
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 by tracing the full /sync handling and device_lists cache logic in the js-sdk, especially how a saved sync token is detected. Verify the behavior when a full sync has no saved token, and consider the issue's proposed cache invalidation; done means newly logged-in devices are discovered after restart and UTD messages are avoided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100