Repository navigation
fix(bot): wait out a near GraphQL rate limit and retry once - #204
Merged
jamesconwaydev merged 1 commit intoNov 6, 2026
Merged
jamesconwaydev merged 1 commit into
jamesconwaydev merged 1 commit into
Conversation
A RATE_LIMITED GraphQL error raised straight away, even when the limit reset in a few seconds. It now gets the same treatment as a REST rate limit: if the reset is within MAX_SLEEP, sleep until then and send the document again once; otherwise raise RateLimited as before. GitHub rejects a rate-limited document before running it, so mutations are retried too.
jamesconwaydev
approved these changes
Nov 6, 2026
jamesconwaydev
left a comment
Collaborator
There was a problem hiding this comment.
Good call making it match the REST path: one wait for a near reset, then raise. I'm happy with mutations getting the retry too, since a RATE_LIMITED document is refused before it runs. Thanks for picking up the last bit of #47.
4 of 5 tasks
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.
What and why
Closes #47. This is the part left open after #199: retrying a GraphQL
RATE_LIMITEDerror instead of raising straight away.graphql()now handles it the way_requesthandles a REST rate limit. Ifx-ratelimit-resetis withinMAX_SLEEP, it sleeps until then and sends the document once more. If the reset is further off, or the retry is limited too, it raisesRateLimitedas before, sospends_attemptand the callers see no change. With no reset header it still assumes a minute.Mutations get the retry too. GraphQL works out a document's point cost before running it, so a rate-limited document never ran and sending it again can't duplicate anything.
Tests: a query and a mutation each get limited once with a reset 30s out, then succeed after one sleep. The existing
test_graphql_rate_limitednow also checks the far-off reset raises without sleeping, and the 60s fallback sleeps once and then raises. Both fail onmain.Checks
python3 -m unittest discover -s scripts -t .passesnpm --prefix site testpasses (if you touchedsite/)npx prettier --check .passesdata/entries.jsonby hand (submissions go through the form)