Skip to content

Throttle our retries when attempting cross-signing reset, and give up after a time limit#6325

Merged
andybalaam merged 3 commits intomainfrom
andybalaam/throttle-cross-signing-reset
Mar 20, 2026
Merged

Throttle our retries when attempting cross-signing reset, and give up after a time limit#6325
andybalaam merged 3 commits intomainfrom
andybalaam/throttle-cross-signing-reset

Conversation

@andybalaam
Copy link
Copy Markdown
Member

@andybalaam andybalaam commented Mar 19, 2026

Related to element-hq/element-x-android#6420

Part of element-hq/element-x-android#5075

I noticed when investigating a bug about resetting your identity when using a MAS login that we poll the server checking whether the user has given us permission with no limit on how fast we poll, and with no ability to give up if it's not working.

This change causes us to retry only twice per second, and give up after 2 minutes. These are guesses as to the right values and I am open to discussion.

  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was not made with the help of AI.

@andybalaam andybalaam force-pushed the andybalaam/throttle-cross-signing-reset branch from 5c0f500 to c6e3451 Compare March 19, 2026 16:00
@andybalaam andybalaam force-pushed the andybalaam/throttle-cross-signing-reset branch from c6e3451 to 5d9c048 Compare March 19, 2026 16:00
@andybalaam andybalaam marked this pull request as ready for review March 19, 2026 16:03
@andybalaam andybalaam requested a review from a team as a code owner March 19, 2026 16:03
@andybalaam andybalaam requested review from Hywan and removed request for a team March 19, 2026 16:03
Copy link
Copy Markdown
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Approving but can't we use the backoff mechanism we have in the HTTP client instead?

Comment thread crates/matrix-sdk/src/encryption/mod.rs Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 19, 2026

Merging this PR will improve performance by 98.97%

⚡ 1 improved benchmark
✅ 49 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation Restore session [memory store] 222.9 ms 112 ms +98.97%

Comparing andybalaam/throttle-cross-signing-reset (89b7603) with main (cbfecf5)

Open in CodSpeed

@andybalaam
Copy link
Copy Markdown
Member Author

Approving but can't we use the backoff mechanism we have in the HTTP client instead?

Hmm, I'm not sure. We want to keep polling fast because at some point the user will click the button in MAS and we want to respond quickly when that happens.

@andybalaam andybalaam requested a review from poljar March 19, 2026 16:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 70.83333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.80%. Comparing base (84ddafb) to head (89b7603).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/encryption/mod.rs 70.83% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6325      +/-   ##
==========================================
- Coverage   89.82%   89.80%   -0.02%     
==========================================
  Files         376      376              
  Lines      102591   102601      +10     
  Branches   102591   102601      +10     
==========================================
- Hits        92152    92144       -8     
- Misses       6857     6872      +15     
- Partials     3582     3585       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Yup

@andybalaam andybalaam merged commit ec97509 into main Mar 20, 2026
53 checks passed
@andybalaam andybalaam deleted the andybalaam/throttle-cross-signing-reset branch March 20, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants