-
Notifications
You must be signed in to change notification settings - Fork 28
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
"API rate limit exceeded" errors #54
Comments
This is very normal and expected. However, it might not be very well explained and handled, so I need to improve that. Go Package Store currently uses a GitHub presenter that does unauthenticated API calls. They have a pretty low rate limit/quota. That means if you run Go Package Store with many, many updates available, you'll likely exhaust the unauthenticated rate limit/quota quite fast. It's usually not a problem for when I use it because I have few updates at a time, but the first time a new user runs it (if they have many packages that are out of date), they're almost guaranteed to run into this. I didn't want to try to hardcode some auth into the code since it's open source and couldn't keep the secret token a secret... Any suggestions? |
How about asking users to generate their own auth token if they run into On Sat, Jan 23, 2016 at 3:09 AM, Dmitri Shuralyov [email protected]
Follow me on twitter @slimsag https://twitter.com/slimsag. |
Yeah, I could have an env var or CLI flag (maybe less preferable because it might show up in |
Thanks for explanation! I don't see any other general solution than providing an auth token. I guess the problem might be somewhat alleviated by caching the responses, but not sure if that would be worth the effort. |
Do you mean caching responses within one session (this is already done), or caching across multiple runs of G-P-S (this is not done and I can consider this option)? |
Yes, I meant across multiple runs. That's exactly how I stumbled upon it, but not sure if that would be common for others (or for me outside of tinkering mode). |
Right. I think it's definitely worth considering doing that. That way, if you run G-P-S a second time after 5 minutes, it will be faster and not use up your unauthenticated rate limit/quota. It will still not help for initial runs when there are many, many packages. It will also not help when you're on a public or shared IP that happens to have the unauthenticated quota used up (because other people made many unauthenticated GH API requests). So an option to provide a GitHub token might still be desirable. But that's an orthogonal feature. About saving state/cache between runs of G-P-S, the main blocker for that is I don't know what's a good location on one's disk to use for such data. It will also vary per operating system. If anyone has suggestions or pointers, that'd be great. I am guessing I'd need to read up on how OSes do this and use the folders they recommend. For example, on Windows, it might be |
I've experimented with using a caching The on-disk cache is a great fit for improving this situation, and when I tried it, it worked correctly, not using up additional rate limit quota after repeated runs. So, I think I know how to resolve this, but this is now blocking on finding a way to come up with a good base path (on disk) for cache. In my testing, I just wrote to the current working directory, but that's not acceptable for production. |
For reference, here's a sample run with a disk cache and some debug logging adding. There are two runs. The first run has no cache, so all requests are cache misses. The second run has the cache from previous run, so all requests happen to be cache hits. Note that the Rate response is cached too, that's why it appears to be the same as in first run (the real rate limit is at 1 of 60 for the hour, so without caching, the second run would run into API rate limit exceeded errors).
|
One potential security consideration to be aware of. If we add both on-disk cache AND a way to provide a secret GitHub API token, then the on-disk cache will contain sensitive information (the secret token). Therefore, we should either not use cache when authentication is provided, or store the cache in a secure location so other users can't access it. |
That sounds like good news. The locations for cache might be the ones you mentioned on Win and OSX, plus The only bit I'm unsure of is the |
Perhaps it should be |
I happened to need the same kind of location for one of my projects, so I wrote down what we discussed here. Feel free to use if you find it helpful: https://github.com/rtfb/cachedir/blob/master/cachedir.go No docs yet, but I've tested it on Linux, OSX and Windows. Assumed all flavours of BSD and Solaris behave same as Linux. |
Thanks @rtfb, that will come in handy. I'm working on a few things that will significantly improve the situation here. First PhaseBetter display of errors in the web UI (and not in terminal). It currently looks something like this: Second PhaseUse an application data directory on local disk to store cache for github presenter. This will help avoid burning through the API rate limit quota when running Go Package Store multiple times, when not much has changed. Third PhaseAdd supprot for an env var to set a GitHub API token in order to do authenticated requests and have a quota of 5000 API calls per hour rather than just 60. I've learned that, luckily, when using authenticated GitHub API clients, the cached responses don't really contain any sensitive data (it's only setting some headers on the requests, not on responses, which are cached). So doing this should be quite accessible without security concerns. |
First phase is mostly complete in #56, but waiting on an external PR to be merged. |
@rtfb, I've created a similar package for Go Package Store's current needs, see Go Package Store will only use the cache dir if it's acquired successfully, otherwise it will fall back to current behavior of not having a persistent cache. |
Helps with #54. Support OS X only for now, expand coverage of other OSes later, with testing. Unsupported systems will behave as before, they'll simply not be using a persistent cache directory.
I've added support for providing a GitHub auth token in ee9b46d (it doesn't need any scopes, it's only used to be authenticated and receive a higher API rate limit). That's phase 3, and it should resolve this issue completely. Please let me know if anything doesn't work as expected. |
Thanks, @shurcooL! |
I'm getting
403 API rate limit exceeded
errors for all GH accesses after I use Go-Package-Store for a while:Is this a glitch or is it some limitation in what GH allows? Anybody else seen this?
The text was updated successfully, but these errors were encountered: