grammyjs / auto-retry

A transformer function for retrying requests.
https://grammy.dev/plugins/auto-retry
MIT License
7 stars 2 forks source link

Share retry after across independent execution contexts #9

Closed KnightNiwrem closed 6 months ago

KnightNiwrem commented 1 year ago

If 429 is triggered by some API call in a middleware or some other independent setTimeout call, other async threads that uses the same sessionKey (i.e. bot api token or id) shall also be aware of the recalculated retry_after value.

This attempts to ensure the 429 -> stop all calls until.. -> start sending model.

KnightNiwrem commented 1 year ago

Rate limits are enforced on a per-method basis. They may affect each other indirectly, but we should delay all calls to the same method—not session key.

Amazing work btw!

Fixed.. I think?

KnorpelSenf commented 8 months ago

@KnightNiwrem how well did you test this?

KnorpelSenf commented 6 months ago

This is not a good idea. For examples, responses to messages might still be sent while broadcasting is slowed down. It makes sense to keep unrelated API call independent, and not apply rate limits of one call to other calls.

Bot developers need to make sure that they don't call a method too many times concurrently.