zulip / zulip-flutter

Upcoming Zulip mobile apps for Android and iOS, using Flutter
Apache License 2.0
200 stars 193 forks source link

Understand rate-limiting responses (429, RATE_LIMIT_HIT) #946

Open gnprice opened 2 months ago

gnprice commented 2 months ago

The Zulip server rate-limits requests. By default the limit for each user is 200 per minute, in total across all types of requests. For an example where this came up, see #945 and its original report.

We'll resolve #945 by having fetchOlder specifically add backoff for the getMessages requests we make there. But then a further bonus refinement would be for us to understand when the server is specifically giving us rate-limiting errors, and follow its instructions for how long to wait before making another request.

For docs on the rate-limiting errors:

To do this right, this logic belongs on ApiConnection. That way the information can be shared across all the different requests we make on behalf of a given account.