Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init runs in to SlackError 429 (rateLimited) #975

Open
kannanmr opened this issue Feb 8, 2024 · 2 comments
Open

Init runs in to SlackError 429 (rateLimited) #975

kannanmr opened this issue Feb 8, 2024 · 2 comments

Comments

@kannanmr
Copy link

kannanmr commented Feb 8, 2024

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'}
@kannanmr
Copy link
Author

kannanmr commented Feb 8, 2024

Failed with the latest version as well slack-machine==0.35.0

@DonDebonair
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants