sleep longer and more when code searching (#24385)
* sleep longer and more when code searching * exponential
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user