-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Basic rate limits #8539
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
base: develop
Are you sure you want to change the base?
Basic rate limits #8539
Conversation
Signed-off-by: Andrey Sobolev <[email protected]>
retryAfter != null | ||
? parseInt(retryAfter, 10) | ||
: rateLimitReset != null | ||
? new Date(parseInt(rateLimitReset, 10)).getTime() - Date.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should not be 10 here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do something like this:
Math.max(new Date(parseInt(rateLimitReset, Date.now())).getTime() - Date.now()), 10)
|
||
console.warn(`Rate limit exceeded. Waiting ${waitTime / 1000} seconds before retrying...`) | ||
await new Promise((resolve) => setTimeout(resolve, waitTime)) | ||
throw new Error(rateLimitError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw after waiting for timeout? I think we should either throw an error or wait, not both. If we waited for XX seconds, then we can safely do requests again
|
||
console.warn(`Rate limit exceeded. Waiting ${waitTime / 1000} seconds before retrying...`) | ||
await new Promise((resolve) => setTimeout(resolve, waitTime)) | ||
throw new Error(rateLimitError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be PlatformError
?
Basic rate limits