matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

Indexed DB can have inconsistency in membership event content

Open AndrewFerr opened this issue 9 months ago • 6 comments

It's possible for the sync store to have incorrect content of a m.room.member event in roomsData.join.$roomID.state[*], but correct content for that same event in roomsData.join.$roomID.timeline[*].

To reproduce:

  • Visit develop.element.io in two tabs, each tab signed in with a different user
  • Create/visit a room that has both users in it
  • Have one user leave the room
  • With the user that remains in the room:
    • Open Element devtools and view Explore room state > m.room.member > MXID of user who left
    • Open browser devtools and view Indexed DB for https://develop.element.io > matrix-js-sdk:riot-web-sync > sync
  • See that Element devtools shows the correct value of content.membership = "leave"
  • See that the Indexed DB has the same value for content.membership in the timeline event for the same eventID
  • See that the Indexed DB has an *incorrect value of content.membership = "join" in the state event for the same eventID

With that said, any client that uses timeline to load state won't have any problems (and I assume Element Web does that, as it has accurate member lists in rooms). But if a client were read from state, it would get incorrect data.

AndrewFerr avatar May 10 '24 17:05 AndrewFerr

For example:

image

Element devtools & Indexed DB are showing the same event (as the room ID & event ID between the two are the same), but they each have a different value for "membership".

The correct content is in the timeline version of the event, though:

image

I assume that, unlike /sync's Joined Room response objects, the js-sdk's Indexed DB state should be a snapshot of the current room state, and not whatever the state was up until the start of timeline. But even if that weren't the case, it's still a problem that two occurrences of the same event in the Indexed DB have different "content"s.

AndrewFerr avatar May 10 '24 17:05 AndrewFerr

Just looking at this for triage, but how are you getting two tabs signed in as different users? I don't see how this would be possible since they share the same localstorage etc: they would be logged in as the same user.

dbkr avatar May 13 '24 10:05 dbkr

To add to the above comment, the app should also show you an error:

Image

MidhunSureshR avatar May 14 '24 07:05 MidhunSureshR