fix: make the function handler timeout 5 seconds#1348
Conversation
| def setup_time_mocks(self, *, monkeypatch: pytest.MonkeyPatch, time_mock: Mock, sleep_mock: AsyncMock): | ||
| monkeypatch.setattr(time, "time", time_mock) | ||
| monkeypatch.setattr(asyncio, "sleep", sleep_mock) | ||
|
|
There was a problem hiding this comment.
This just make the tests run faster 🚀
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1348 +/- ##
==========================================
- Coverage 90.96% 90.95% -0.01%
==========================================
Files 222 222
Lines 7501 7507 +6
==========================================
+ Hits 6823 6828 +5
- Misses 678 679 +1 ☔ View full report in Codecov by Sentry. |
zimeg
left a comment
There was a problem hiding this comment.
@WilliamBergamin LGTM! And what an interesting addition to Bolt! ⚡
If I'm understanding right, this change avoids warning outputs for function_executed events if the application doesn't respond in time which will match the Slack API server behavior?
Testing found this new timeout works as expected but I did leave a few comments that'd be nice to address before merging this.
It might also be nice to note that 3 seconds is no longer a strict requirement for certain events in docs: https://docs.slack.dev/tools/bolt-python/concepts/acknowledge/ 📚
|
|
||
| # await for the completion of ack() in the async listener execution | ||
| while ack.response is None and time.time() - starting_time <= 3: | ||
| while ack.response is None and time.time() - starting_time <= listener.acknowledgement_timeout: |
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
Summary
The
function_executedevent is the only event with a timeout longer then 3 seconds, this PR aims to allow bolt to timeout function handlers after 5 seconds rather then 3. This will allow developer to callackup to 5 seconds after they receive thefunction_executedevent.Testing
scripts/build_pypi_package.shcommandCategory
slack_bolt.Appand/or its core componentsslack_bolt.async_app.AsyncAppand/or its core componentsslack_bolt.adapter/docsRequirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
./scripts/install_all_and_run_tests.shafter making the changes.