Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rate limiting retry middleware #45

Open
bluekeyes opened this issue Jun 18, 2020 · 1 comment
Open

Add rate limiting retry middleware #45

bluekeyes opened this issue Jun 18, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@bluekeyes
Copy link
Member

It would be helpful if the client creator provided an option to enable delays and retries in case of rate limiting. This should be optional because GitHub's hourly buckets mean you might have to wait a long time to try again. This also implies there should be an option for a maximum wait time, so if the retry header is past this value, the request can fail immediately. I expect this will be most useful if accidentally hitting the abuse limits (where the wait time is probably minutes), but could also be useful for regular limits.

@bluekeyes bluekeyes added the enhancement New feature or request label Jun 18, 2020
@bluekeyes
Copy link
Member Author

One catch: if an event blocks waiting to retry and then additional events are processed while it is waiting, the final observed state may be inconsistent. For instance, consider Policy Bot:

  1. A pull request event happens, Policy Bot reads and caches partial PR state, and then blocks on the last read API call
  2. A comment event happens while the first one is blocked, Policy Bot evaluates and posts a success status
  3. The first event unblocks, finishes evaluating to pending (it does not see the comment from 2) and then "reverts" the status on the pull request in GitHub

Theoretically, the event in 2 will also block due to the non-expired rate limit, and the first event will wake up first, but this still seems like a potential race condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant