1
0
mirror of synced 2025-12-20 02:19:14 -05:00

sleep longer and more when code searching (#24385)

* sleep longer and more when code searching

* exponential
This commit is contained in:
Peter Bengtsson
2022-01-18 15:08:52 -05:00
committed by GitHub
parent acc178e571
commit 96e16d7ee6

View File

@@ -170,7 +170,7 @@ async function searchCode(q, perPage, currentPage) {
}
}
async function secondaryRateLimitRetry(callable, args, maxAttempts = 5) {
async function secondaryRateLimitRetry(callable, args, maxAttempts = 10, sleepTime = 1000) {
try {
const response = await callable(args)
return response
@@ -185,7 +185,6 @@ async function secondaryRateLimitRetry(callable, args, maxAttempts = 5) {
//
// Let's look for that an manually self-recurse, under certain conditions
const lookFor = 'You have exceeded a secondary rate limit.'
const sleepTime = 5000 // ms
if (
err.status &&
err.status === 403 &&
@@ -199,7 +198,7 @@ async function secondaryRateLimitRetry(callable, args, maxAttempts = 5) {
)
return new Promise((resolve) => {
setTimeout(() => {
resolve(secondaryRateLimitRetry(callable, args, maxAttempts - 1))
resolve(secondaryRateLimitRetry(callable, args, maxAttempts - 1, sleepTime * 2))
}, sleepTime)
})
}