processBeforeRepsonse: true doesn't work when a Bolt listener function has WebClient calls inside
See original GitHub issueDescription
When deploying a Bolt app to AWS Lambda, and using processBeforeResponse
option, the listener is not able to complete before the HTTP response is finished.
This issue was reported by a user in the Slack Community workspace: https://community.slack.com/archives/CHY642221/p1585670255001600.
Requirements (place an x
in each of the [ ]
)
- 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 searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 2.0.0
node version: NA
OS version(s): NA
Steps to reproduce:
-
Use the following code:
const { App, ExpressReceiver } = require('@slack/bolt'); const expressReceiver = new ExpressReceiver({ signingSecret: process.env.SLACK_SIGNING_SECRET }); const app = new App({ token: process.env.SLACK_BOT_TOKEN, receiver: expressReceiver, processBeforeResponse: true }); // ------------------------ // Application Logic // ------------------------ app.event('app_home_opened', async ({ context, event, say }) => { console.log(`event: ${JSON.stringify(event)}`); await say(`Hello world, and welcome <@${event.user}> from AWS Lambda.`); console.log("finish to say"); });
-
Deploy to AWS Lambda
-
Open the App Home in Slack to trigger the event subscription.
Expected result:
User should receive the message sent using say()
, and the logs should show “finish to say”.
Actual result:
There’s no message and the line does not appear in the logs.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
processBeforeRepsonse: true doesn't work when a Bolt ...
When deploying a Bolt app to AWS Lambda, and using processBeforeResponse option, the listener is not able to complete before the HTTP response...
Read more >Bolt for Python - Slack Platform Developer Tools
To listen to messages that your app has access to receive, you can use the message() method which filters out events that aren't...
Read more >(Slack API Bolt project) Using Context object to pass property ...
I've removed the initialization of a new WebClient object. In Bolt v1.6.0 and later, there is a client argument available in listeners and ......
Read more >@slack/bolt - npm
Start using @slack/bolt in your project by running `npm i @slack/bolt`. ... before the listener function to only call that listener function ......
Read more >views.open method - Slack API
Access to a resource specified in the request is denied. account_inactive. Authentication token is for a deleted user or workspace when using a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for working on this and I’m happy to know you’ve figured out the cause! The above explanation is very clear and that makes sense a lot to me.
I haven’t verified if applying the fix on conversation store fixes the issue yet. If you need someone to double-check, I can do that. But if you’re already confident enough, let’s ship the fix as soon as possible.
As I shared above, the main issue we’re still tackling is that
processBeforeRepsonse: true
doesn’t work when a Bolt listener function hasWebClient
calls inside.HTTP requests by axios always run separately from an async listener/middleware function. I’m still not sure if there is a way to take control from the Bolt framework side (even not sure if it’s specific to axios or it can happen with other 3rd parties yet).
In my understanding, there are three options here:
axios
HTTP requests run as part of Bolt’s async functionssetTimeout
internallyack()
manually in Events API listeners (the approach I originally proposed at #395 ) and removeprocessBeforeResponse
@aoberoi @stevengill @shaydewael I’d like to know your thoughts on this.
I prefer 0️⃣ > 2️⃣ > 1️⃣ but I can agree with any decision. For 0️⃣, I don’t have the bandwidth to take it this week, so that I would like someone else (any contributions from the community are of course welcome!) to do a deep dive.