question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

processBeforeRepsonse: true doesn't work when a Bolt listener function has WebClient calls inside

See original GitHub issue

Description

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:

  1. 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");
    });
    
  2. Deploy to AWS Lambda

  3. 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:closed
  • Created 3 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
seratchcommented, Apr 10, 2020

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.

2reactions
seratchcommented, Apr 7, 2020

As I shared above, the main issue we’re still tackling is that processBeforeRepsonse: true doesn’t work when a Bolt listener function has WebClient 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:

  • 0️⃣Continue seeking a way to ensure axios HTTP requests run as part of Bolt’s async functions
  • 1️⃣Go with #459 wait for acknowledgment by having while loop + await Promise that does setTimeout internally
  • 2️⃣ Allow developers to call ack() manually in Events API listeners (the approach I originally proposed at #395 ) and remove processBeforeResponse

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found