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

Add a message ID on each to-device message #2938

Merged
merged 6 commits into from
Dec 6, 2022
Merged

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Dec 2, 2022

To make it easier to track down where to-device messages are getting lost,
add a custom property to each one, and log its value. Synapse will also log
this property.

We will emit log lines such as:

Enqueuing batch of to-device messages. type=m.room.encrypted txnid=m1670257675639.2 [ "@alice:localhost:8482/QSEDQLTFJA (msgid d0bd05e5-1fa3-410c-b1b5-c541ec99aa1b)",  "@bob:localhost:8482/SJGHSKJDH (msgid 0852cdaa-1546-4af7-87fb-07f3350be64f)" ]

and

received to-device m.room.encrypted from: @testuser82:localhost:8482 id: e354f925-a583-4b71-94d8-7864589ded29

part of element-hq/element-meta#558

See also matrix-org/synapse#14598 for the server side bits.


Here's what your changelog entry will look like:

✨ Features

  • Add a message ID on each to-device message (#2938).

To make it easier to track down where to-device messages are getting lost,
add a custom property to each one, and log its value. Synapse will also log
this property.
package.json Outdated Show resolved Hide resolved
... because apparently more recent versions are too esm-ed for the embedded build
Copy link
Member

@robintown robintown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greatly appreciated, I do wonder though if there's a more foolproof way of doing this such that IDs don't have to be sprinkled throughout the SDK. Would it be possible to insert the ID in MatrixClient.sendToDevice?

.when("PUT", "/sendToDevice/m.room.encrypted")
.check((request) => {
const data = request.data;
delete data.messages["@bob:example.org"]["bobweb"]["org.matrix.msgid"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you can use "org.matrix.msgid": expect.any(String) in the expect statement

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, TIL.

@richvdh
Copy link
Member Author

richvdh commented Dec 5, 2022

Would it be possible to insert the ID in MatrixClient.sendToDevice?

Well, it turns out that actually breaks some to-device messages (in particular, some of those used in verification), because it breaks their signatures, so I don't think that would be a good approach. Also, for messages that go via the queue, we want to assign IDs to messages before they are queued, to make sure we can trace them right through.

I do agree though, it feels very repetitive and boilerplatey. I considered some sort of assignIDandSendToDevice method, but decided that was probably more opaque and no more reliable than just generating an ID alongside the message.

Copy link
Member

@robintown robintown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case this is fine

@richvdh richvdh merged commit 683e7fb into develop Dec 6, 2022
@richvdh richvdh deleted the rav/ids_for_to_device branch December 6, 2022 10:31
richvdh added a commit that referenced this pull request Dec 6, 2022
#2938 introduced message IDs on
outgoing to-device messages, but a typo meant that the IDs on key-share
messages were excessive.
richvdh added a commit that referenced this pull request Dec 6, 2022
#2938 introduced message IDs on
outgoing to-device messages, but a typo meant that the IDs on key-share
messages were excessive.
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Jan 15, 2023
* Process `m.room.encryption` events before emitting `RoomMember` events ([\matrix-org#2914](matrix-org#2914)). Fixes element-hq/element-web#23819.
* Don't expose `calls` on `GroupCall` ([\matrix-org#2941](matrix-org#2941)).
* Support MSC3391: Account data deletion ([\matrix-org#2967](matrix-org#2967)).
* Add a message ID on each to-device message ([\matrix-org#2938](matrix-org#2938)).
* Enable multiple users' power levels to be set at once ([\matrix-org#2892](matrix-org#2892)). Contributed by @GoodGuyMarco.
* Include pending events in thread summary and count again ([\matrix-org#2922](matrix-org#2922)). Fixes element-hq/element-web#23642.
* Make GroupCall work better with widgets ([\matrix-org#2935](matrix-org#2935)).
* Add method to get outgoing room key requests for a given event ([\matrix-org#2930](matrix-org#2930)).
* Fix messages loaded during initial fetch ending up out of order ([\matrix-org#2971](matrix-org#2971)). Fixes element-hq/element-web#23972.
* Fix #23919: Root message for new thread loaded from network ([\matrix-org#2965](matrix-org#2965)). Fixes element-hq/element-web#23919.
* Fix #23916: Prevent edits of the last message in a thread getting lost ([\matrix-org#2951](matrix-org#2951)). Fixes element-hq/element-web#23916 and element-hq/element-web#23942.
* Fix infinite loop when restoring cached read receipts ([\matrix-org#2963](matrix-org#2963)). Fixes element-hq/element-web#23951.
* Don't swallow errors coming from the shareSession call ([\matrix-org#2962](matrix-org#2962)). Fixes element-hq/element-web#23792.
* Make sure that MegolmEncryption.setupPromise always resolves  ([\matrix-org#2960](matrix-org#2960)).
* Do not calculate highlight notifs for threads unknown to the room ([\matrix-org#2957](matrix-org#2957)).
* Cache read receipts for unknown threads ([\matrix-org#2953](matrix-org#2953)).
* bugfix: sliding sync initial room timelines shouldn't notify ([\matrix-org#2933](matrix-org#2933)).
* Redo key sharing after own device verification ([\matrix-org#2921](matrix-org#2921)). Fixes element-hq/element-web#23333.
* Move updated threads to the end of the thread list ([\matrix-org#2923](matrix-org#2923)). Fixes element-hq/element-web#23876.
* Fix highlight notifications increasing when total notification is zero ([\matrix-org#2937](matrix-org#2937)). Fixes element-hq/element-web#23885.
* Fix synthesizeReceipt ([\matrix-org#2916](matrix-org#2916)). Fixes element-hq/element-web#23827 element-hq/element-web#23754 and element-hq/element-web#23847.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants