matrix-org / matrix-org/matrix-rust-sdk

`Client::login` should support retries in case of 429 / Too Many Requests

Open
#828 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

I'm using matrix-rust-sdk both in CI and for non-trivial bots that may require many clients.

Right now, Client::login uses a RequestConfig::short_retry(), ignoring any RequestConfig we may have passed in ClientBuilder::request_config, which makes the method fail if the server responds with a 429. This means that I need to manually retry my logins. It's definitely possible, but it's both ugly code and easy to get wrong.

I'd like the ability to have a Client::login that I can just trust to retry.

One possibility would be to introduce a method

impl ClientBuilder {
   /// Specify a `RequestConfig` to use during login, e.g. for retrying.
   ///
   /// By default, `ClientBuilder` assumes that its users wish to be informed quickly if they client
   /// cannot connect to a homeserver and will use the specialized `RequestConfig::short_retry()`
   /// to fail early.
   ///
   /// Use this method to e.g. enable further retries in case of 429 "Too Many Requests".
   pub fn login_request_config(self, RequestConfig) -> Self;
}

Caveat: In terms of API design, it's a bit odd.

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 at the Client::login and ClientBuilder entry points, then trace how RequestConfig::short_retry() is selected and how ClientBuilder::request_config is currently used. Resolve the API-design question around a login-specific configuration, and consider the 429 retry behavior the issue describes done when login can reliably apply the intended retry configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.