Skip to content

feat: surface ack_timeout on the handler - #1351

Merged
WilliamBergamin merged 3 commits into
mainfrom
make-function-timout-custom
Aug 22, 2025
Merged

feat: surface ack_timeout on the handler#1351
WilliamBergamin merged 3 commits into
mainfrom
make-function-timout-custom

Conversation

@WilliamBergamin

@WilliamBergaminWilliamBergamin commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

Summary

These changes aim to surface ack_timeout at the function handler level. This allows developers to set their own custom timeout for the acknowledgement, this comes in handler when dealing with dynamic options or new function types that may allow for a timeout greater then 3 seconds

Testing

Set up an app with the following function handler

@app.function("search", auto_acknowledge=False, ack_timeout=5)defhandle_search_step_event(
ack: Ack, inputs: dict, fail: Fail, complete: Complete, logger: logging.Logger
):
logger.info("Function inputs received:")
logger.info(f"inputs: {json.dumps(inputs, indent=2)}")
sleep(4)
complete(outputs={...})

Bolt will allow your handler to take up to 5 seconds before returning an error response to Slack

Configuring the handler with auto_acknowledge=true (default behavior)

@app.function("search", ack_timeout=5)defhandle_search_step_event(
ack: Ack, inputs: dict, fail: Fail, complete: Complete, logger: logging.Logger
):
logger.info("Function inputs received:")
logger.info(f"inputs: {json.dumps(inputs, indent=2)}")
...

Will print a warning indicating that ack_timeout has no effect

WARNING:slack_bolt.App:As you gave `client` as well, `token` will be unused.
WARNING:slack_bolt.App:On @app.function("search"), as `auto_acknowledge` is `True`, the `acknowledgement_timeout=5` you gave will be unused
INFO:slack_bolt.App:A new session has been established (session id: a7bd6667-e9db-45dc-8419-468afbf5e5ea)

Feedback

Instead of naming this acknowledgement_timeout should e name it ack_timeout? 🟢

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

Comment threadslack_bolt/app/app.py Outdated
matchers: Optional[Sequence[Callable[..., bool]]] = None,
middleware: Optional[Sequence[Union[Callable, Middleware]]] = None,
auto_acknowledge: bool = True,
acknowledgement_timeout: int = 3,

@WilliamBergaminWilliamBergaminAug 21, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we name this ack_timeout rather then acknowledgement_timeout?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: ack_timeout makes sense to me and matches the ack parameter well! 📚 ✨

@codecov

codecovBot commented Aug 21, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.96%. Comparing base (76f7027) to head (7f440d7).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@ Coverage Diff @@## main #1351 +/- ##
==========================================
- Coverage 90.96% 90.96% -0.01% 
==========================================
Files 222 222 Lines 7507 7517 +10 ==========================================
+ Hits 6829 6838 +9 - Misses 678 679 +1 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zimegzimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilliamBergamin LGTM! Awaited ack seems so good for tasks needing time 👾 ✨

I left a few comments of thoughts and idea but nothing blocking. Your suggestion of ack_timeout is solid IMHO 👀

Comment threadslack_bolt/app/app.py Outdated
matchers: Optional[Sequence[Callable[..., bool]]] = None,
middleware: Optional[Sequence[Union[Callable, Middleware]]] = None,
auto_acknowledge: bool = True,
acknowledgement_timeout: int = 3,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: ack_timeout makes sense to me and matches the ack parameter well! 📚 ✨

Comment on lines +189 to +192
assert (
f'WARNING On @app.function("{callback_id}"), as `auto_acknowledge` is `True`, `{timeout_argument_name}={kwargs[timeout_argument_name]}` you gave will be unused'
in caplog.text
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quibble: Hardcoding the expected outputs might make this output more immediate at a glance! I'm not so familiar with kwargs I must admit 😔

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used kwargs in the test in order to assert that the parameter name shown in the warning is the one defined by the function 🤔 I think we should leave it for now but we don't need to make this a common pattern

@WilliamBergaminWilliamBergamin changed the title feat: surface acknowledgement_timeout on the handlerfeat: surface ack_timeout on the handlerAug 22, 2025

@zimegzimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilliamBergamin LGTM and I'm so optimistic in the change to match ack around- 👾 ✨

@WilliamBergamin
WilliamBergamin merged commit c0ea30f into mainAug 22, 2025
14 checks passed
@WilliamBergamin
WilliamBergamin deleted the make-function-timout-custom branch August 22, 2025 20:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@WilliamBergamin@zimeg