-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a throttling plugin to the used Octokit instance to retry request…
…s after hitting secondary rate limits (#286) * fix: prevent hitting github secondary rate limits Adds the octokit plugin for throttling / rate-limiting to fix the problem where action runs get blocked with a 403 error[1]. The `github.getOctokit`[2] function accepts a list of plugins, so this passes in the `throttling` plugin[3] to be hooked into the octokit instance. It also needs some configuration to setup the `throttle` mechanisms, passed in to the `getOctokit` function. [1]: #192 [2]: https://github.com/actions/toolkit/blob/main/packages/github/src/github.ts#LL18C40-L18C40 [3]: https://github.com/octokit/plugin-throttling.js * refactor: change rate limit callback signatures Based on additional docs, the callbacks seem to have changes to their signatures[1]. This change aligns this implementation with the docs[2]. [1]: https://octokit.github.io/rest.js/v19#throttling [2]: https://github.com/octokit/plugin-throttling.js/blob/v5.1.1/src/index.ts#L90-L91 * chore: add changeset * wire up typed throttle options * Upgrade TS * refactor: use console based logging * Update .changeset/rotten-carrots-pump.md --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
Showing
4 changed files
with
122 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@changesets/action": patch | ||
--- | ||
|
||
This patch implements the [`@octokit/plugin-throttling`](https://github.com/octokit/plugin-throttling.js) plugin and [wires | ||
it up with the internal GitHub Octokit instance](https://github.com/actions/toolkit/tree/457303960f03375db6f033e214b9f90d79c3fe5c/packages/github#extending-the-octokit-instance). | ||
|
||
This plugin is recommended by [the Octokit docs](://octokit.github.io/rest.js/v19#throttling) as it implements all the GitHub [best practices for integrators](https://docs.github.com/en/rest/guides/best-practices-for-integrators?apiVersion=2022-11-28). | ||
|
||
This should help with `changesets/action` gitting spurious secondary rate limits and failing CI jobs, for which the only known workaround is to simply re-run the job. |
This file contains 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
This file contains 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
This file contains 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