Skip to content

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Basic rate limits #8539

wants to merge 1 commit into from

Conversation

haiodo
Copy link
Member

@haiodo haiodo commented Apr 14, 2025

Basic rate limits

Signed-off-by: Andrey Sobolev <[email protected]>
retryAfter != null
? parseInt(retryAfter, 10)
: rateLimitReset != null
? new Date(parseInt(rateLimitReset, 10)).getTime() - Date.now()
Copy link
Member

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

Copy link
Member

@aonnikov aonnikov Apr 15, 2025

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be PlatformError?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants