question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong Rate limits

See original GitHub issue

Hello, I try to found the best way to handle rate limits but I have some strange behaviors

const handleError = (err) => {
  const {
    shortTermUsage,
    shortTermLimit,
  } = strava.rateLimiting
  console.lg(shortTermUsage, shortTermLimit)

  throw new Error(err.message)
}

const payload = await strava.athlete.listActivities(args).catch(errors.StatusCodeError, handleError)

The error is: 429 - {"message":"Rate Limit Exceeded","errors":[{"resource":"Application","field":"rate limit","code":"exceeded"}]}

But shortTermUsage is 574 while shortTermLimit is 600

So my script stop. The next time I start my script and I go to handleError, shortTermUsage and shortTermLimit are equal to 0 like not initialized.

Did I miss something?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
markstoscommented, Feb 3, 2020

Sounds right. PR welcome.

On Mon, Feb 3, 2020, 4:22 AM Cédric Delpoux notifications@github.com wrote:

The object strava.rateLimiting is correct most of the time except when the first fetch thow an error, for example if rate limit exceeded before the first fetch.

I did not try but I think we need to call rateLimiting.updateRateLimits in a catch or a finally here https://github.com/UnbounDev/node-strava-v3/blob/ee850ac6dba9b52457f84717a9d2ed4fad21fe31/lib/httpClient.js#L191

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/UnbounDev/node-strava-v3/issues/84?email_source=notifications&email_token=AAAGJZPQPJTW3IFRVO7UXLDRA7O53A5CNFSM4KL4LASKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKTC5HA#issuecomment-581316252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGJZKRZXNS62WM3B3FVJDRA7O53ANCNFSM4KL4LASA .

0reactions
cedricdelpouxcommented, Feb 3, 2020

I just did

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is rate limiting? | Rate limiting and bots - Cloudflare
Rate limiting blocks users, bots, or applications that are over-using or abusing a web property. Rate limiting can stop certain kinds of bot...
Read more >
Rate Limit Exceeded errors | Plaid Docs
Guide to understanding and troubleshooting errors returned when the request is valid but has exceeded established rate limits.
Read more >
What to do when you are being rate limited
Rate limiting is a way of controlling the amount of requests handled by the site's API (Application Program Interface) — these communications are...
Read more >
How to handle rate limits & errors - Klaviyo Developers
All endpoints are rate limited. Check the response codes for a 429 error, which indicates you have hit a rate limit, and retry...
Read more >
Twitter 'rate limit' messages are due to an error, not your bad ...
We've seen those “rate limit exceeded” messages too, and contacted Twitter to find out what's going on. A Twitter spokesperson tells Engadget ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found