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.

Ratelimit not being handled correctly?

See original GitHub issue

So I use username and password to authenticate:

this._r = new Snoowrap({
    userAgent: '...',
    clientId: '...',
    clientSecret: '...',
    username: '...',
    password: '...'
});

So I basically calll getNew at a certain interval to fetch the new submissions and if the conditions are met then I will also reply to that submission:

 this._r.getNew(subreddit).then(function(submissions) {
     _.each(submissions, function(submission) {
         if (.....) {
             submission.reply(text);
         }
     });
 });

And for some reason I get Ratelimit errors after a while:

May 09 15:49:13 twitch-mirrorer app/web.1:  Unhandled rejection Error: RATELIMIT,je doet dat te veel, probeer het over 3 minuten opnieuw.,ratelimit 
May 09 15:49:13 twitch-mirrorer app/web.1:      at /app/node_modules/snoowrap/dist/helpers.js:111:11 
May 09 15:49:13 twitch-mirrorer app/web.1:      at PassThroughHandlerContext.finallyHandler (/app/node_modules/bluebird/js/release/finally.js:57:23) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at PassThroughHandlerContext.tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:614:10) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:693:18) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at Immediate.Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:17:14) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at runCallback (timers.js:672:20) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at tryOnImmediate (timers.js:645:5) 
May 09 15:49:13 twitch-mirrorer app/web.1:      at processImmediate [as _immediateCallback] (timers.js:617:5) 

Did I assume wrongly that the API would handle the rate limit correctly and prevent sending requests when the rate limit has been reached?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, May 9, 2017

Actually, I realized my first comment was incorrect – that error isn’t coming from the normal ratelimit of 600 requests per second. Reddit prevents accounts with low karma from posting too frequently, to deter spam. (You’ll notice this if you try to post comments too frequently from a new account, regardless of whether you’re using the API.) If you get some karma on your bot’s account, I think the posting limit will go away.

0reactions
TheHolyWafflecommented, May 9, 2017

I guess that clears it all up. Thank you for the quick help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rate Limit handling may not work with GitHub Enterprise #1318
In the code at github/github.go#L766, it parses the response body to check if the message starts with the words "API rate limit exceeded...
Read more >
Be prepared: 3 ways to handle rate limits | by Cathal Horan
While the reset option is one way to deal with rate limiting, you may want more granular control over your rate limit handling....
Read more >
How to Stop Being Rate Limited: Best Practices for Making API ...
Not handling rate limits properly can lead to the following issues: Account Suspension: Accounts that continually violate rate limits can be ...
Read more >
API host's rate-limit header not read properly - Stack Overflow
But the "X-***-Ratelimit" header is clearly not being read correctly, as when I do console.log(limitHeader); console.log(rateLimit);.
Read more >
Rate limit best practices - Okta Developer
The best way to be sure about org-wide rate limits is to check the relevant headers in the response. The System Log ...
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