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

Exempt initial requests from ratelimits #510

Merged
merged 5 commits into from
Jul 9, 2021

Conversation

eritbh
Copy link
Member

@eritbh eritbh commented Jul 9, 2021

Potentially fixes an issue where Toolbox would intermittently not load when a page is first loaded.

Adds an additional argument to Ratelimiter#request, an options object which influences how the ratelimiter processes the request. The only current option is bypassLimit, which causes the request to be sent immediately when it is added to the queue, without checking if the current bucket still has requests remaining. This option is passed by TBApi.getJSON as bypassRatelimit and is used exclusively by the requests made when Toolbox is first loading in order to prevent them from blocking all of Toolbox.

Also includes some light restructuring of the Ratelimiter class - added type annotations to its properties and switched to storing pending requests as objects rather than array. Also added typedefs for the relevant interfaces.

The ESLint ecmaVersion bump is compatible with all our supported browsers and allows for the ... spread notation for object properties, which is used here.

@eritbh eritbh added bug something isn't working core: background labels Jul 9, 2021
@eritbh eritbh added this to the v5.6.1 milestone Jul 9, 2021
@eritbh eritbh requested a review from creesch July 9, 2021 02:17
@creesch creesch merged commit 692ab4b into master Jul 9, 2021
@creesch creesch deleted the exempt-initial-requests-from-ratelimits branch July 9, 2021 13:47
eritbh added a commit that referenced this pull request Sep 5, 2024
* Add support for bypassing ratelimits

* Store pending requests as objects for clarity

* Add types to the rest of these props for fun

* Use bypassRatelimit for initial info requests

* bypassLimit is in the request options, derp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working core: background
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants