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

Bug | Sticky event maps register several events for the same sticky key

Open
#5,205 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

O-Occasional S-Major T-Defect
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`

Image

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

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/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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.