matrix-js-sdk
matrix-js-sdk copied to clipboard
Indexed DB can have inconsistency in membership event content
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
- Open Element devtools and view Explore room state >
- 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 thetimeline
event for the same eventID - See that the Indexed DB has an *incorrect value of
content.membership
="join"
in thestate
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.
For example:
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:
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.
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.
To add to the above comment, the app should also show you an error: