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

Working with Github rate limits #43

Closed
jasperweyne opened this issue Jan 4, 2024 · 2 comments
Closed

Working with Github rate limits #43

jasperweyne opened this issue Jan 4, 2024 · 2 comments

Comments

@jasperweyne
Copy link

TailwindBundle will query Github for the latest CLI binary each time tailwind:build is executed. When actively developing and trying things out while building manually (without running with --watch, executing the command), a user may quickly exceed the maximum of 60reqs per hour to the Github API. This unnecessarily disallows offline development as well.

Workaround
A simple workaround is to set the binary version manually, as this skips the check of the latest binary, eg.

symfonycasts_tailwind:
    binary_version: 'v3.4.0'

However, a user may want to not set this value, to ensure that the binary is updated as soon as possible.

Possible fixes
There are multiple options to fix this and multiple of these solutions could be implemented together. Here, I'm listing some ideas.

  1. An option would be allowing the user to make authenticated requests in the same manner as Composer does, increasing the maximum to 5000reqs per hour.
  2. Another option would be to cache the latest version string.
  3. Another option would be to simply use any available binary when a 4**/5** response is returned.
  4. Another option would be to load the full Tailwind css from PlayCDN during development (see PlayCDN Support? #42 ). This has downsides though: it wouldn't allow for offline development, and it wouldn't help if any custom configuration of Tailwind was used.
@bocharsky-bw
Copy link
Member

Hm yeah, caching the version for a short period of time (probably max up to 1h is would fix this issue). But not sure how it would be better to do it, add a required cache dependency? :/ Go with something custom, like storing the latest version in a temporary file?

Also, using any available bin sounds reasonable too, it's already downloaded anyway, so why not use it if exists when 4xx/5xx occur, this will fix not only rate limit problem but offline problem as well which is cool.

About authenticated requests - that seems an overkill in this specific situation IMO, it just feels like we're trying to ignore the problem of frequent requests with a hack.

@weaverryan
Copy link
Contributor

Hm yeah, caching the version for a short period of time (probably max up to 1h is would fix this issue). But not sure how it would be better to do it, add a required cache dependency

That seems fine to me. The user will have the cache component already in practice, so adding it as a dependency would not be a big deal. I would cache the version that was found. Then, I would always make an API request. But if it fails, fallback to trying to look for the version in cache. PR welcome!

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 a pull request may close this issue.

3 participants