Ratelimit not being handled correctly?
See original GitHub issueSo 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:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
I guess that clears it all up. Thank you for the quick help 😃