matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
465 stars 150 forks source link

IRC messages sent within a second of each other can be bridged in the wrong order #1688

Open progval opened 1 year ago

progval commented 1 year ago

I just posted a link to IRC, and a bot immediately replied with its title:

08:09:56 <+vlorentz> https://hacky.town/@rtyler/110023261891172425
08:09:57 <+swhbot> ^ R Tyler Croy 🦀: "Docker Inc would like to thank the open source co…" - Hacky Town!
08:10:27 --> zack[m]1 (~zacchirom@2001:470:69fc:105::167f) has joined #swh-offtopic

Both messages appeared in the wrong order on matrix.org:

Screenshot 2023-03-15 at 09-16-20 Element #swh-offtopic

But this is not due to federation re-ordering. As can be seen in the original_server_ts, the bridge created the second message 5 milliseconds before the first:

{
  "content": {
    "body": "https://hacky.town/@rtyler/110023261891172425",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1678867814656,
  "sender": "@vlorentz:libera.chat",
  "type": "m.room.message",
  "unsigned": {},
  "event_id": "$bI_KHdDQ4IBAuZn5tMtlqmvR5dJPNxjtSRYVv4HN23w",
  "room_id": "!kRyriktPylyYEcqFIP:libera.chat"
}
{
  "content": {
    "body": "^ R Tyler Croy 🦀: \"Docker Inc would like to thank the open source co…\" - Hacky Town!",
    "format": "org.matrix.custom.html",
    "formatted_body": "^ R Tyler Croy 🦀: &quot;Docker Inc would like to thank the open source co…&quot; - Hacky Town!",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1678867814651,
  "sender": "@swhbot:libera.chat",
  "type": "m.room.message",
  "unsigned": {},
  "event_id": "$atz8n9nFy3HvKKk4_jrEIq29bIlagv9-wDvrLyFgDv0",
  "room_id": "!kRyriktPylyYEcqFIP:libera.chat"
}

Possibly relevant: the room was inactive before these two messages so the puppet of an unkickable user was disconnected (#1564), but messages were not dropped because we have allowUnconnectedMatrixUsers configured to true

bkil commented 1 year ago

Possibly related. I've pasted a very long message on Matrix. It was split to 3 messages over IRC, but the order of the messages was reversed (i.e., last part got in first).