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

Getting repeated slack events request in case of failure #845

Closed
mohan-raheja opened this issue Mar 8, 2023 · 4 comments
Closed

Getting repeated slack events request in case of failure #845

mohan-raheja opened this issue Mar 8, 2023 · 4 comments
Labels
question Further information is requested

Comments

@mohan-raheja
Copy link

I'm using slack events in my app

@app.event("team_join")
and @app.event("user_change")

to detect any new users added to the team or any updateds for the user

In case of failure in handling the events due to some issues in our internal logic, I'm getting repeated events request from slack, want to know how to avoid these in case of failure in handling the event.

Reproducible in:

slack-bolt==1.9.1
slack-sdk==3.11.1

@srajiang srajiang added the question Further information is requested label Mar 8, 2023
@srajiang
Copy link
Contributor

srajiang commented Mar 8, 2023

Hi @mohan-raheja - Slack Events API will retry (with exponential backoff) all requests that go unacknowledged from your app up to 3 times. There is a way to provide a header to turn off retries, see here: https://api.slack.com/apis/connections/events-api#retries-off.

Let me see whether Bolt Python provides a way to set that header when you set up the app.

@srajiang
Copy link
Contributor

srajiang commented Mar 8, 2023

Hey @mohan-raheja - You can register an app.error callback, a global error handler. Errors of type BoltError and others error types (from your app) will cause this middleware to run, and there you may set the BoltResponse status and headers yourself. Here's an example

You can try using this to set X-Slack-No-Retries header to turn retries off, for instance. https://api.slack.com/apis/connections/events-api#retries-off

Hope that helps!

@seratch
Copy link
Contributor

seratch commented Mar 9, 2023

Another approach is to have a custom global middleware that checks the retry-num in a request. As I mentioned at #731 (comment), it is not generally recommended (because resolving the timeouts is ideal). That being said, if the approach works well for your use case, it's an option too.

@mohan-raheja
Copy link
Author

Thank you, it helped.

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

No branches or pull requests

3 participants