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

Client Events on Users not reliable

Open
#2,535 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.2k
Forks
704
Avg merge
1d 20h
Merged PRs (30d)
40

Description

**Describe the bug**
When you try to listen to User events like `User.presence`, these will not always be triggered.
For example when using an IndexedDBStore, the Cached and Created users will not reemit any events.

My understanding is, that users created through the sync-method `createNewUser`(1) will react to changes from the sync API and reemit events and every other User, that just gets created like `new User(...)` will not.
These "dumb" User models are created in the IndexedDBStore (2) and MemoryStore (3) (so in every case you wanted to use client-caching) and with your own User in startClient (4).

## References:
* [(1) createNewUser](https://github.com/matrix-org/matrix-js-sdk/blob/5367ee18fbd2e87cc2fe4f71e4b678a7c620ab80/src/sync.ts)
* [(2) IndexedDBStore::startup](https://github.com/matrix-org/matrix-js-sdk/blob/5367ee18fbd2e87cc2fe4f71e4b678a7c620ab80/src/store/indexeddb.ts)
* [(3) MemoryStore::onRoomMember](https://github.com/matrix-org/matrix-js-sdk/blob/5367ee18fbd2e87cc2fe4f71e4b678a7c620ab80/src/store/memory.ts)
* [(4) MatrixClient::startClient](https://github.com/matrix-org/matrix-js-sdk/blob/5367ee18fbd2e87cc2fe4f71e4b678a7c620ab80/src/client.ts)

Should every service that needs to create user models depend on the sync helper?

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

Compare the user creation paths in src/sync.ts, src/store/indexeddb.ts, src/store/memory.ts, and src/client.ts, starting with createNewUser and the referenced startup, onRoomMember, and startClient entry points. Determine which instances receive sync updates and reemit events; the issue is done when cached, created, and client-owned Users have reliable event behavior or the supported creation contract is clearly established.

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
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.