Skip to content

Comments

feat: extend ack timeout for function executed events#2645

Merged
WilliamBergamin merged 9 commits intomainfrom
poc-custom-ack-timeout
Oct 21, 2025
Merged

feat: extend ack timeout for function executed events#2645
WilliamBergamin merged 9 commits intomainfrom
poc-custom-ack-timeout

Conversation

@WilliamBergamin
Copy link
Contributor

Summary

This PR aims to extend the default ack timeout from 3 seconds to 10 seconds for function_executed events received over HTTP and Express receiver

Testing

  1. lack create -t slack-samples/bolt-ts-custom-step-template
  2. Modify the app so that it uses the HTTP receiver or Express receiver
const { App, LogLevel, ExpressReceiver } = require('@slack/bolt');

const receiver = new ExpressReceiver({
  signingSecret: process.env.SLACK_SIGNING_SECRET,
});

const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  appToken: process.env.SLACK_APP_TOKEN,
  logLevel: LogLevel.INFO,
  receiver: receiver
});
  1. Modify the function handler so that it manually handles ack behavior, and sleeps for 9 seconds
function sleep(seconds) {
  return new Promise((resolve) => {
    setTimeout(resolve, seconds * 1000);
  });
}

app.function('sample_step', { autoAcknowledge: false }, async ({ ack, inputs, complete, fail, logger }) => {
  logger.info('sleeping');
  await sleep(9);
  logger.info('done sleeping');

   await complete!({ outputs: { user_id: user.id } });
   wait ack();
})
  1. You may experience retries or failures from the Slack backend but this isn't the goal of these changes, what should be noted is that Bolt does not invoke the unhandledRequestHandler, does not print an error and does not response to the request with a 404

Requirements (place an x in each [ ])

@WilliamBergamin WilliamBergamin self-assigned this Sep 5, 2025
@WilliamBergamin WilliamBergamin added enhancement M-T: A feature request for new functionality semver:minor labels Sep 5, 2025
@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.44%. Comparing base (559a7a7) to head (06e9ae5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/receivers/HTTPReceiver.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2645      +/-   ##
==========================================
+ Coverage   93.42%   93.44%   +0.01%     
==========================================
  Files          37       37              
  Lines        7636     7668      +32     
  Branches      666      669       +3     
==========================================
+ Hits         7134     7165      +31     
- Misses        497      498       +1     
  Partials        5        5              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

this.isAcknowledged = false;
this.processBeforeResponse = args.processBeforeResponse;
this.unhandledRequestHandler = args.unhandledRequestHandler ?? httpFunc.defaultUnhandledRequestHandler;
this.unhandledFunctionRequestTimeoutMillis = 10001;
Copy link

Choose a reason for hiding this comment

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

Since we might want to change the timeout in webapp, do we want to start with something smaller like 5sec?

Copy link

@cchensh cchensh left a comment

Choose a reason for hiding this comment

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

The change LGTM and it's a simple solution for now. Personally I'm fine with starting with 10 secs but we do want to keep boltjs, bolt python and webapp timeout consistent - it's worth documenting somewhere for the future

@phantom541
Copy link

Yo yo yo

@phantom541
Copy link

Guys I'm working on a large scale whatsapp bot
Was wondering if u could put in a Heloise g hand for lil bro
I'm new to coding and stuff
Please help 🙏

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@WilliamBergamin LGTM! This is a nice approach to make certain listeners more flexible in response to function events 🔮

One suggestion before merging might change the warning outputs here to use a variable "seconds" value instead of a hardcoded 3? I missed the change from "10" to "5" seconds and was wondering if these changes were being used at first...

// The default unhandledRequestHandler implementation:
// Developers can customize this behavior by passing unhandledRequestHandler to the constructor
// Note that this method cannot be an async function to align with the implementation using setTimeout
export const defaultUnhandledRequestHandler = (args: ReceiverUnhandledRequestHandlerArgs): void => {
const { logger, response } = args;
logger.error(
'An incoming event was not acknowledged within 3 seconds. ' +
'Ensure that the ack() argument is called in a listener.',
);

Comment on lines +68 to +71
* 2. Refactor Bolt App and Receivers to implement proper Request and Response abstractions:
* - Receivers should translate their specific request types to standardized Bolt Requests/Responses
* - All acknowledgment behaviors and default routing should be handled by the App, not the receivers
* - Prevent multiple request body parsing happening both here and again in the App
Copy link
Member

Choose a reason for hiding this comment

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

⭐ praise: The idea of bolt requests and responses I think is so good as a shared interface. IIRC some oauth receivers could use this too?

@WilliamBergamin WilliamBergamin merged commit 3a8953c into main Oct 21, 2025
19 checks passed
@WilliamBergamin WilliamBergamin deleted the poc-custom-ack-timeout branch October 21, 2025 21:28
@zimeg zimeg added this to the 4.6.0 milestone Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants