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

Handling of 429 errors is weird #2152

Open
benoit74 opened this issue Feb 6, 2025 · 0 comments
Open

Handling of 429 errors is weird #2152

benoit74 opened this issue Feb 6, 2025 · 0 comments
Labels

Comments

@benoit74
Copy link
Contributor

benoit74 commented Feb 6, 2025

private getJSONCb = <T>(url: string, handler: (...args: any[]) => any): void => {
logger.info(`Getting JSON from [${url}]`)
axios
.get<T>(url, this.jsonRequestOptions)
.then((a) => handler(null, a.data), handler)
.catch((err) => {
try {
if (err.response && err.response.status === 429) {
logger.log('Received a [status=429], slowing down')
const newMaxActiveRequests: number = Math.max(this.maxActiveRequests - 1, 1)
logger.log(`Setting maxActiveRequests from [${this.maxActiveRequests}] to [${newMaxActiveRequests}]`)
this.maxActiveRequests = newMaxActiveRequests
return this.getJSONCb(url, handler)
} else if (err.response && err.response.status === 404) {
handler(err)
}
} catch (a) {
logger.log('ERR', err)
handler(err)
}
})
}

I have following interrogations:

  • why do we only decrease the level of parallelism? to me, the general intent of 429 error is to ask for a pause, not to ask for less requests in parallel (even if obviously this has an impact)
  • this code looks like a trap, there is no escape, we might fell stuck in this loop forever since we might continue to call too often, and the upstream might continue to ask to slow down with a 429 error
  • why don't we use the backoff mechanism which is already in place, so that we make a pause + the pause is exponentially long?
  • why is this implement only for getJSONCb method? 429 could happen in any HTTP call (aside S3 ones probably) so this should be more generic from my PoV

WDYT?

@benoit74 benoit74 added the bug label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant