fix: respect challenge rate limits#1211
Merged
AttackingOrDefending merged 1 commit intoJun 4, 2026
Merged
Conversation
MarkZH
reviewed
May 30, 2026
50dcb88 to
a1c0576
Compare
Contributor
Author
|
@MarkZH updated the test assertions to use seconds() instead of raw floats |
a1c0576 to
bd91a33
Compare
MarkZH
reviewed
Jun 1, 2026
Treat generic 429 responses from the challenge endpoint as bot rate limits, honoring Retry-After when present and otherwise using bounded exponential backoff. Also prevent expired outgoing challenges from bypassing the local challenge rate-limit timer. Validation: - python3 -m py_compile lib/lichess.py lib/matchmaking.py test_bot/test_lichess.py test_bot/test_matchmaking.py - python -m ruff check lib/lichess.py lib/matchmaking.py test_bot/test_lichess.py test_bot/test_matchmaking.py - python -m pytest test_bot/test_lichess.py::test_challenge_429_without_ratelimit_body_sets_bot_rate_limit test_bot/test_lichess.py::test_challenge_429_without_retry_after_uses_exponential_backoff test_bot/test_matchmaking.py::test_should_create_challenge_respects_rate_limit_when_previous_challenge_expired
bd91a33 to
e396724
Compare
MarkZH
approved these changes
Jun 3, 2026
AttackingOrDefending
approved these changes
Jun 4, 2026
38d3446
into
lichess-bot-devs:master
23 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Treat generic 429 responses from the challenge endpoint as bot rate limits, honoring Retry-After when present and otherwise using bounded exponential backoff. Also prevent expired outgoing challenges from bypassing the local challenge rate-limit timer.
Validation:
Type of pull request:
Description:
Treat generic 429 responses from the challenge endpoint as bot rate limits, honoring
Retry-Afterwhenpresent and otherwise using bounded exponential backoff. Also prevent expired outgoing challenges from
bypassing the local challenge rate-limit timer.
This treats generic challenge 429s as bot rate limits, honors
Retry-Afterwhen present, falls back tobounded exponential backoff, and prevents expired outgoing challenges from bypassing the local rate-
limit timer.
Validation:
python3 -m py_compile lib/lichess.py lib/matchmaking.py test_bot/test_lichess.py test_bot/ test_matchmaking.pypython -m ruff check lib/lichess.py lib/matchmaking.py test_bot/test_lichess.py test_bot/ test_matchmaking.pypython -m pytest test_bot/ test_lichess.py::test_challenge_429_without_ratelimit_body_sets_bot_rate_limit test_bot/ test_lichess.py::test_challenge_429_without_retry_after_uses_exponential_backoff test_bot/ test_matchmaking.py::test_should_create_challenge_respects_rate_limit_when_previous_challenge_expiredRelated Issues:
[Reference any related issues that this pull request addresses or closes. Use the syntax
Closes #issue_numberto automatically close the linked issue upon merging.]Checklist:
Screenshots/logs (if applicable):