slack-machine
slack-machine copied to clipboard
Init runs in to SlackError 429 (rateLimited)
Our workspace is a big one (typical of any medium to large corporate). The initial call to form channel_list is throwing a rateLimited SlackError. I looked through the code for rate_limit_errors handling, dont see any. Is there an option for this, or a fix for this is in the works?
I am running slack-machine==0.32.0
$ slack-machine
2024-02-07 15:12:04 [info ] Initializing Slack Machine...
2024-02-07 15:12:04 [info ] Loading settings...
2024-02-07 15:12:04 [info ] Custom init done.
2024-02-07 15:12:04 [info ] Settings loaded!
Traceback (most recent call last):
File "/src/venv/bin/slack-machine", line 8, in <module>
sys.exit(main())
^^^^^^
File "/src/venv/lib/python3.11/site-packages/machine/bin/run.py", line 19, in main
loop.run_until_complete(bot.run())
File "/src/.pyenv/versions/3.11.5/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/src/venv/lib/python3.11/site-packages/machine/core.py", line 264, in run
await self._setup()
File "/src/venv/lib/python3.11/site-packages/machine/core.py", line 77, in _setup
await self._setup_slack_clients()
File "/src/venv/lib/python3.11/site-packages/machine/core.py", line 118, in _setup_slack_clients
await self._client.setup()
File "/src/venv/lib/python3.11/site-packages/machine/clients/slack.py", line 119, in setup
async for page in await self._client.web_client.conversations_list(
File "/src/venv/lib/python3.11/site-packages/slack_sdk/web/async_slack_response.py", line 161, in __anext__
return self.validate()
^^^^^^^^^^^^^^^
File "/src/venv/lib/python3.11/site-packages/slack_sdk/web/async_slack_response.py", line 203, in validate
raise e.SlackApiError(message=msg, response=self)
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://www.slack.com/api/conversations.list, status: 429)
The server responded with: {'ok': False, 'error': 'ratelimited'}
Failed with the latest version as well slack-machine==0.35.0
Hey @kannanmr thanks for the report. I have never encountered this due to using Slack Machine only on smaller workspaces (~150 members). It's good that you brought this to light!
Because I have never encountered this myself (nor have others ever reported this), I'm not working on a fix yet. I can try to figure out a fix, but it will be hard for me to implement a fix, let alone test it, as I do not have access to a workspace where this would happen.
Are you open to try and implement a fix? From what I can see in the documentation, Slack Machine would need to catch the ratelimit (HTTP 429) error and then read the Retry-After
header to see how many seconds it has to wait before making a new request.
Trying to use this in an org of 15,000 people. Also rate limited.
Temporarily fixed by boosting the limit of the requests to 1000...turns out we have 67,000 users not 15,000. I will try to set up some sort of error handling. Edit: crashed anyways trying to load all the conversations. Not sure this is going to work on an org this size...
Opened #1115