matrix-org / matrix-org/matrix-js-sdk
Bug | Sticky event maps register several events for the same sticky key
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 704
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 40
Description
I was building a devtool utility for sticky events, and I noticed that the `_unstable_getStickyEvents` returns several events per unique `msc4354_sticky_key`
This is unexpected, there should be only one active sticky event per sticky key.
The problem is that the sticky key is in the event content and is encrypted.
But the `unstableStickyExpiresAt` is at the event root.
## What happens
1. The SDK consider an encrypted event as sticky (because there is a `unstableStickyExpiresAt` in the event)
2. Then it tries to get the `msc4354_sticky_key` in the content. But it fails because the event is not yet decrypted (decryptionPromise is pending)
3. So the event is added in the list of `unkeyed` events [unkeyedStickyEvents](https://github.com/matrix-org/matrix-js-sdk/blob/5739b59faaf33fa55457dcaa76ffebe0506d1466/src/models/room-sticky-events.ts#L51), that is events that have no sticky key.
later on the event is decrypted (and mutated in place), but it wrongly stays in the `unkeyedStickyEvents` list!
## What should happen
The `RoomStickyEventsStore` should wait for event to be decrypted before processing it
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/models/room-sticky-events.ts, especially RoomStickyEventsStore and the unkeyedStickyEvents handling linked from the issue. Reproduce the case with an encrypted sticky event whose decryptionPromise is pending, then trace how the event changes after decryption. Done means decrypted events are processed with their sticky key so only one active event remains for each key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100