I read issue #305 that explained that giving a retryConfig object for WebClient it would be possible to disable the retry operation but it actually isn't (I explain properly on steps to reproduce).
On your docs is: https://slackapi.github.io/node-slack-sdk/web_api#changing-the-retry-configuration.
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
@slack/client version: 3.15.0
node version: 8.9.3
OS version(s): Ubuntu 16.04 LTS
Rate limited errors. (make sure you're using a token from a workspace which have a good amount of channels, otherwise it could take long)const { WebClient } = require('@slack/client')
const SLACK_USER_TOKEN='<token here>'
const slack = new WebClient(SLACK_USER_TOKEN, { retryConfig: { retries: 0 }, maxRequestConcurrency: Infinity })
for (let i = 1; i <= 1000; i++) {
slack.channels.list()
.catch(e => console.log('this never gets called'))
}
I expected that @slack/client would throw an error so I can throttle API calls myself.
@slack/client is automatically retrying.
It seems handleRateLimitResponse is a special case and doesn't really use the library retry.
thanks for point that out @gunar. you're right, and the docs don't specify whether the retry configuration should apply for rate-limited requests. the key information is buried in the code comments:
@rodrigo4244 can i take this issue to mean that you have a feature request for turning rate-limit handling off in the WebClient?
Thanks @aoberoi! I already edited the title and the message to reflect that! Let me know as soon as this is up and running. Thanks!
@rodrigo4244 lets try to define what "working properly" might mean for you. do you simply want an on/off switch so you can say "do not retry any rate-limited requests"? or do you want the existing retryConfig to apply to rate-limited requests just the same as requests that fail for other reasons (network interruptions, minor service downtime, etc)? or do you want a fully independent rateLimitRetryConfig that applies differently to rate-limited requests (leaving retryConfig to only apply to the other failure reasons)?
@aoberoi I want rateLimitRetryConfig!
I just didn't want rate limited requests to be automatically retried and, instead, I want them to throw.
same here
thanks for the feedback @rodrigo4244 and @gunar! i'm happy to work on getting this feature into master on a v4 version of this package. if you'd rather see it landed on v3, please let me know so we can make another issue to track that separately.
@aerobi whatever is fastest. Thank you!!
Hey folks, I've refactored the code where retries occur in a substantial way for #596. This has opened the door for me to build a new option to address this need too. I'd like to confirm with you all whether you'd be satisfied by what I'm planning on adding.
proposal: a new rejectRateLimitedCalls boolean configuration option for the WebClient constructor. the default would be false, but when set to true, the client would return a rejected promise (or invoke your callback) with an Error. This error would be of interface (in the TypeScript sense) WebAPIRateLimitedError. The error would also have a retryAfter property, that contains the number of seconds to wait, according to the HTTP response from Slack.
Edit: Changed interface from WebAPIPlatformError to a new WebAPIRateLimitedError.
Most helpful comment
Hey folks, I've refactored the code where retries occur in a substantial way for #596. This has opened the door for me to build a new option to address this need too. I'd like to confirm with you all whether you'd be satisfied by what I'm planning on adding.
proposal: a new
rejectRateLimitedCallsboolean configuration option for theWebClientconstructor. the default would befalse, but when set totrue, the client would return a rejected promise (or invoke your callback) with an Error. This error would be of interface (in the TypeScript sense)WebAPIRateLimitedError. The error would also have aretryAfterproperty, that contains the number of seconds to wait, according to the HTTP response from Slack.Edit: Changed interface from
WebAPIPlatformErrorto a newWebAPIRateLimitedError.