Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit ae22296

Browse files
authored
do not retry on secondary limits (#380)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Refactor:** - Replaced `warning` import with a `console.log` statement in `src/octokit.ts`. - Added a condition to check the retry count before logging and returning `true`. - Updated `onSecondaryRateLimit` function to log rate limit information directly. - Removed the `retry` configuration object. > 🎉 Here's to the code that's leaner, not meaner, > To the logs that are clearer, making debugging no fearer. > With each retry counted, and rate limits mounted, > We've refactored and pruned, and a victory is sounded! 🥳 <!-- end of auto-generated comment: release notes by openai -->
1 parent 955c447 commit ae22296

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/octokit.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {getInput, warning} from '@actions/core'
1+
import {getInput} from '@actions/core'
22
import {Octokit} from '@octokit/action'
33
import {retry} from '@octokit/plugin-retry'
44
import {throttling} from '@octokit/plugin-throttling'
@@ -13,26 +13,24 @@ export const octokit = new RetryAndThrottlingOctokit({
1313
onRateLimit: (
1414
retryAfter: number,
1515
options: any,
16-
_o: any,
16+
_o: typeof Octokit,
1717
retryCount: number
1818
) => {
19-
warning(
19+
console.log(
2020
`Request quota exhausted for request ${options.method} ${options.url}
2121
Retry after: ${retryAfter} seconds
2222
Retry count: ${retryCount}
2323
`
2424
)
25-
return true
25+
if (retryCount <= 3) {
26+
console.log(`Retrying after ${retryAfter} seconds!`)
27+
return true
28+
}
2629
},
27-
onSecondaryRateLimit: (_retryAfter: number, options: any) => {
28-
warning(
29-
`SecondaryRateLimit detected for request ${options.method} ${options.url}`
30+
onSecondaryRateLimit: (retryAfter: number, options: any) => {
31+
console.log(
32+
`SecondaryRateLimit detected for request ${options.method} ${options.url} ; retry after ${retryAfter} seconds`
3033
)
31-
return true
3234
}
33-
},
34-
retry: {
35-
doNotRetry: ['429'],
36-
maxRetries: 3
3735
}
3836
})

0 commit comments

Comments
 (0)