Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synapse does not correctly send device-list-un-tracked indications in /sync responses when lazy-loading is enabled #16948

Closed
richvdh opened this issue Feb 21, 2024 · 1 comment · Fixed by #16949
Assignees

Comments

@richvdh
Copy link
Member

richvdh commented Feb 21, 2024

  • Alice is in a room, and uses lazy-loading of memberships
  • Charlie joins the room. Alice sees the join event in her sync, together with a device_lists update:
    {
      "next_batch":"s7_2_0_1_1_1_1_4_0_1",
      "device_lists":{"changed":["@user-3-charlie:hs1"]},
      "rooms":{"join":{"!RcwoXhPrnmxBAlwqGb:hs1":{
        "timeline":{
          "events":[
            {"type":"m.room.member","sender":"@user-3-charlie:hs1","content":{"membership":"join","displayname":"user-3-charlie"},"state_key":"@user-3-charlie:hs1","origin_server_ts":1708524078957,"unsigned":{"age":22},"event_id":"$qq0CJ2AtNKVNGaYZkRiNpnirejAH8zvkWZ2DQh_ftBc"}
          ],
          "prev_batch":"s6_2_0_1_1_1_1_4_0_1",
          "limited":false
        },
        "state":{"events":[]}
      }}}
    }
  • Charlie sends a message, and then leaves the room. Alice syncs again. The server returns both of Charlie's events, and another device_lists update:
    {
      "next_batch":"s9_4_0_1_1_1_1_4_0_1",
      "device_lists":{"left":["@user-3-charlie:hs1"]},
      "rooms":{"join":{"!RcwoXhPrnmxBAlwqGb:hs1":{
        "timeline":{
          "events":[
            {"type":"m.room.message","sender":"@user-3-charlie:hs1","content":{"body":"test0","msgtype":"m.text"},"origin_server_ts":1708524078982,"unsigned":{"age":56},"event_id":"$mxxcBMt7WBKGVC84XMerO1O5Kd1GOoATGaChzHhCOqY"},
            {"type":"m.room.member","sender":"@user-3-charlie:hs1","content":{"membership":"leave"},"state_key":"@user-3-charlie:hs1","origin_server_ts":1708524079008,"unsigned":{"replaces_state":"$qq0CJ2AtNKVNGaYZkRiNpnirejAH8zvkWZ2DQh_ftBc","prev_content":{"membership":"join","displayname":"user-3-charlie"},"prev_sender":"@user-3-charlie:hs1","age":30},"event_id":"$1vNTMX633F6JSBoZCb981mGIBE0QTyJ4C4bnAtYt0Jc"}
          ],
          "prev_batch":"s7_4_0_1_1_1_1_4_0_1",
          "limited":false
        },
        "state":{"events":[]}
      }}}
    }
  • So far so good. However, the sync response gets dropped, and Alice syncs again using the same sync token. Charlie's join event is now (redundantly) included in the state section of the response, but more worryingly, Charlie is now listed under "changed" rather than "left" in the device lists section:
    {
      "next_batch":"s9_4_0_1_1_1_1_4_0_1",
      "device_lists":{"changed":["@user-3-charlie:hs1"]},
      "rooms":{"join":{"!RcwoXhPrnmxBAlwqGb:hs1":{
        "timeline":{
          "events":[
            {"type":"m.room.message","sender":"@user-3-charlie:hs1","content":{"body":"test0","msgtype":"m.text"},"origin_server_ts":1708524078982,"unsigned":{"age":64},"event_id":"$mxxcBMt7WBKGVC84XMerO1O5Kd1GOoATGaChzHhCOqY"},
            {"type":"m.room.member","sender":"@user-3-charlie:hs1","content":{"membership":"leave"},"state_key":"@user-3-charlie:hs1","origin_server_ts":1708524079008,"unsigned":{"replaces_state":"$qq0CJ2AtNKVNGaYZkRiNpnirejAH8zvkWZ2DQh_ftBc","prev_content":{"membership":"join","displayname":"user-3-charlie"},"prev_sender":"@user-3-charlie:hs1","age":38},"event_id":"$1vNTMX633F6JSBoZCb981mGIBE0QTyJ4C4bnAtYt0Jc"}
          ],
          "prev_batch":"s7_4_0_1_1_1_1_4_0_1",
          "limited":false
        },
        "state":{"events":[
          {"type":"m.room.member","sender":"@user-3-charlie:hs1","content":{"membership":"join","displayname":"user-3-charlie"},"state_key":"@user-3-charlie:hs1","origin_server_ts":1708524078957,"unsigned":{"age":89},"event_id":"$qq0CJ2AtNKVNGaYZkRiNpnirejAH8zvkWZ2DQh_ftBc"}
        ]}
      }}}
    }
@richvdh richvdh self-assigned this Feb 21, 2024
richvdh added a commit that referenced this issue Feb 21, 2024
Fixes #16948. If the `join` and the
`leave` are in the same sync response, we need to count them as a "left" user.
@richvdh
Copy link
Member Author

richvdh commented Feb 21, 2024

Test case at matrix-org/complement#714

richvdh added a commit that referenced this issue Mar 14, 2024
…6949)

Fixes #16948. If the `join`
and the `leave` are in the same sync response, we need to count them as
a "left" user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant