-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Unable to select next Libraries.io token from pool #9839
Comments
OK, so I did a bit of digging into this. I've found at least 2 problems. One of which we can solve, one of which we can't: Problem 1When we calculate
we are calculating a number of milliseconds. In shields/core/token-pooling/token-pool.js Lines 75 to 77 in 4ba8617
we are comparing So we're never going to reset the token because we're trying to compare a number like This has probably been a bug in our code for a eery long time. We can fix this by setting const nextReset = ((Date.now() + (retryAfter ? +retryAfter * 1000 : 0)) / 1000) >>> 0 in Problem 2Libraries.io no longer returns a Keeping track of our own rate limit with no external source is going to be really difficult because we run across multiple servers - we'd have to centralise the count. For the moment, I've opened an issue upstream librariesio/libraries.io#3283 but I have limited faith we will get a response. At the moment, we are flooding sentry with a lot of |
As a temporary position, I've dropped us down to a single libraries.io API key in production. This will mean we serve working badges more often because with a single token, we disable the pooling and don't attempt to keep track of the rate limit. We just use the same token for all requests whether we think we have rate limit left or not. That said, with a single token we won't have enough rate limit for all requests, so we will still serve broken badges once we hit the limit and start getting 429s from upstream. I think for in the immediate term, that is this is the best solution we've got. |
Now that librariesio/libraries.io#3351 is merged, I've switched production back to using 2 tokens. This gets us back to where we were before librariesio/libraries.io@6c400b5 happened. I'm hoping this will eliminate or at least reduce the number of 429s we're seeing from libraries.io. I'll keep an eye on this. I've also submitted #10074 which makes a couple of other tweaks to the polling code that come out of looking into this. |
Are you experiencing an issue with...
shields.io
🐞 Description
Libraries.io badges frequently show
Unable to select next Libraries.io token from pool
🔗 Link to the badge
example:
(but affects all libraries.io badges)
💡 Possible Solution
I think there's 2 issues we need to fix here:
We are doing enough traffic on libraries.io that we are sometimes exhausting the rate limit on our available tokens. We either need to add another token to the pool or cache for longer to try and fix this.
When we do hit the point where none of the tokens in the pool have any rate limit points left, we don't seem to recover from it well. In reality, if we wait for a bit, the next hour will tick over and we can start using the tokens again, but once we exhaust the pool once we're basically just stuck forever (or until the server cycles). We need to be more resilient to recovering from this state if we do hit it.
The text was updated successfully, but these errors were encountered: