matrix-org / matrix-org/matrix-js-sdk

We don't appear to be retrying `/sendToDevice` requests

Open
#1,866 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

T-Defect
Dominant language
TypeScript
Stars
2.2k
Forks
704
Avg merge
1d 20h
Merged PRs (30d)
40

Description

I don't think we're retrying failed `/sendToDevice` requests. [This comment](https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L1634) seems to agree.

This is especially bad when e.g. sharing room keys in `encryptAndSendKeysToDevices` since we might end up [marking a key as sent](https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L634) to a device when in reality the request failed. Though I'm not sure whether the `then(...)` is executed if the request fails or not.

All call sites:

- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L634
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L686
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L780
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L1552
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L1635
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/algorithms/megolm.ts#L1823
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/index.ts#L3313
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/OutgoingRoomKeyRequestManager.ts#L481
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/SecretStorage.ts#L402
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/SecretStorage.ts#L423
- https://github.com/matrix-org/matrix-js-sdk/blob/96e8f65af7429339dbed4bc8063b893b4a0966ce/src/crypto/SecretStorage.ts#L525

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the `/sendToDevice` implementation and the listed call sites in `src/crypto/algorithms/megolm.ts`, `src/crypto/index.ts`, `src/crypto/OutgoingRoomKeyRequestManager.ts`, and `src/crypto/SecretStorage.ts`. Trace how rejected requests reach each `then(...)`, especially `encryptAndSendKeysToDevices`. Done means failed requests are retried consistently and a key is not marked as sent when delivery failed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cryptography, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.