Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack prints failed with the error "operation_timeout" when slack command runs and finishes successfully in AWS Lambda #1435

Closed
5 of 10 tasks
nicolls1 opened this issue Apr 28, 2022 · 2 comments · Fixed by #1452
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
Milestone

Comments

@nicolls1
Copy link
Contributor

nicolls1 commented Apr 28, 2022

Description

Using an ExpressReceiver with AWS Lambda causes successfully run commands to finish with the error failed with the error "operation_timeout".

I was able to diagnose that lambda keeps function running because there is an open setTimeout so the function waits for the timeout to run before finishing the lambda invocation. Thanks to the recent updates, I was able to set the option unhandledRequestTimeoutMillis to a low number and made the unhandledRequestHandler an empty function like so:

    unhandledRequestHandler: () => {},
    unhandledRequestTimeoutMillis: 50,

After setting these two values, slack no longer shows the operation_timeout error to the user. I am aware of the AwsLambdaReceiver and that this may not be the prescribed usage. Just wanted to document this behavior for anyone else that might come across it. Also, with the processBeforeResponse option, it seems like there is some desire for the ExpressReceiver to work in the AWS Lambda environment.

Feel free to close if you don't see any changes being needed and what I suggested as a good enough work around. If there are some thoughts for changes, let me know what you'd like to see and I might be able to put up a PR.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

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: 3.11.0

node version: 14

OS version(s): AWS Lambda

Steps to reproduce:

  1. Setup an app with ExpressReceiver
  2. Deploy the app to AWS lambda behind API Gateway
  3. Added a command handler with app.command('/my-command', () => {...})
  4. Call the command in an installed workspace
  5. The command will run and post a reply to the channel but after a few seconds Slack will say failed with the error "operation_timeout"
  6. Logging the timing on when the handler function starts and exits shows that the function finishes quickly yet AWS shows the lambda as running for more than 3 second

Expected result:

The command will succeed and not post an operation_timeout to the user.

Actual result:

The command will succeeds but the user is shown an error.

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

@seratch seratch added the bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented label Apr 29, 2022
@seratch seratch modified the milestones: 3.12.0, 3.11.1 Apr 29, 2022
@seratch
Copy link
Member

seratch commented Apr 29, 2022

Hi @nicolls1, thanks for sharing this. We haven't observed this behavior in the past but the AWS Lambda runtime might be changed to respect setTimeout completion recently. Either way, to improve this, the setTimeout can be cleared (meaning bolt-js can do clearTimeout to flush the background job) when the response to Slack is submitted. We will improve this in future versions.

@asontha
Copy link

asontha commented Jan 27, 2023

Hello! I'm getting this error as well. I expressly ack the slash command right at the beginning of the handler.

// The /ask command entry point.
app.command('/ask', async ({ command, ack, client, logger }) => {

  // Acknowledge shortcut request
  await ack();

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants