slackapi / bolt-js

A framework to build Slack apps using JavaScript
https://tools.slack.dev/bolt-js/
MIT License
2.74k stars 393 forks source link

expired_trigger_id before 3000ms #1662

Closed htran9 closed 1 year ago

htran9 commented 1 year ago

Description

Describe your issue here.

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

Requirements (place an x in each of the [ ])


Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version: 16.x

OS version(s):

Steps to reproduce:

  1. Run slash command to open modal.

Expected result:

When the slash command is entered, a modal view opens up.

Actual result:

I get a timeout with the following errors:

{
    "statusCode": 500,
    "body": "Internal server error"
}

Attachments:

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

Description: I have been dealing with this trigger_id expire issue intermittently where the failed with the error "operation_timeout" would randomly occurs. From looking at the lambda time duration, it seems like it is under the 3seconds required for an acknowledgement. The timeout is random in that sometimes it would occur when the time duration is 800ms and sometimes it would run fine at 1100ms. The Lambda init time hovers around at 800-1100ms.

The program retrieves the slack credentials that is stored in an SSM.

Log for when the timeout occurs:

START RequestId: Version: $LATEST
2022-11-22T05:09:06.692Z    DEBUG   [DEBUG]  web-api:WebClient:0 initialized
2022-11-22T05:09:06.693Z    DEBUG   [DEBUG]  web-api:WebClient:0 apiCall('auth.test') start
2022-11-22T05:09:06.695Z    DEBUG   [DEBUG]  web-api:WebClient:0 http request url: https://slack.com/api/auth.test
2022-11-22T05:09:06.695Z    DEBUG   [DEBUG]  web-api:WebClient:0 http request body: {
    "token": "[[REDACTED]]"
}
2022-11-22T05:09:06.695Z    DEBUG   [DEBUG]  web-api:WebClient:0 http request headers: {
    "Authorization": "[[REDACTED]]"
}
2022-11-22T05:09:06.954Z    DEBUG   [DEBUG]  web-api:WebClient:0 http response received
2022-11-22T05:09:06.955Z    DEBUG   [DEBUG]  web-api:WebClient:0 http request result: {
    "ok": true,
   ...
   ...
   ...
    "is_enterprise_install": false,
    "response_metadata": {
        "scopes": [
            "chat:write",
            "channels:join",
            "commands",
            "incoming-webhook",
            "channels:read"
        ]
    }
}
2022-11-22T05:09:06.955Z    DEBUG   [DEBUG]  web-api:WebClient:0 apiCall('auth.test') end
2022-11-22T05:09:07.012Z        DEBUG   [DEBUG]  web-api:WebClient:1 initialized
2022-11-22T05:09:07.015Z        DEBUG   [DEBUG]  web-api:WebClient:1 apiCall('views.open') start
2022-11-22T05:09:07.015Z        DEBUG   [DEBUG]  web-api:WebClient:1 http request url: https://slack.com/api/views.open
2022-11-22T05:09:07.015Z        DEBUG   [DEBUG]  web-api:WebClient:1 http request body: {
   ...
   ...
}
2022-11-22T05:09:07.112Z        DEBUG   [DEBUG]  web-api:WebClient:1 http request headers: {}
2022-11-22T05:09:07.277Z        DEBUG   [DEBUG]  web-api:WebClient:1 http response received
2022-11-22T05:09:07.277Z        DEBUG   [DEBUG]  web-api:WebClient:1 http request result: {
    "ok": false,
    "error": "expired_trigger_id",
    "response_metadata": {
        "scopes": [
            "chat:write",
            "channels:join",
            "commands",
            "incoming-webhook",
            "channels:read"
        ]
    }
}
2022-11-22T05:09:07.292Z        ERROR   [ERROR]  bolt-app Error: An API error occurred: expired_trigger_id
    at platformErrorFromResult (/var/task/node_modules/@slack/web-api/dist/errors.js:56:33)
    at WebClient.apiCall (/var/task/node_modules/@slack/web-api/dist/WebClient.js:181:56)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'slack_webapi_platform_error',
  data: {
    ok: false,
    error: 'expired_trigger_id',
    response_metadata: { scopes: [Array] }
  }
}
2022-11-22T05:09:07.292Z        ERROR   [ERROR]   An unhandled error occurred while Bolt processed an event
2022-11-22T05:09:07.292Z        INFO     {
    "statusCode": 500,
    "body": "Internal server error"
}

trigger_id expire: Screen Shot 2022-11-21 at 9 39 33 PM

Duration: Screen Shot 2022-11-21 at 9 31 36 PM

Code:

const awsLambdaReceiver = new AwsLambdaReceiver({
        signingSecret: (await this.getSlackSigningSecret()) as string,
 });

const app = new App({
        token: await this.getSlackToken(),
        logLevel: LogLevel.DEBUG,
        stateSecret: 'my-state-secret',
        scopes: ['channels:history', 'chat:write', 'commands'],
        receiver: awsLambdaReceiver,
 });
app.command('/slashcommand', async ({ body, ack, client }) => {
        await ack();
        await client.views.open({
          trigger_id: body.trigger_id,
          view: commandOptionModal(),
        });
});
app.view('callback_id', async ({ ack, body, view, payload }) => {
        await ack();
});

Thanks,

seratch commented 1 year ago

Hi @htran9, thanks for asking the question! We are still unsure about the cause of your situation but we received a similar question with bolt-python. My reply there may be helpful to you: https://github.com/slackapi/bolt-python/issues/772

htran9 commented 1 year ago

Hey @seratch, I saw that post earlier and tried the suggestions that you have provided, but did not get the issue resolved. I figured I ask to see if the problem was on my end or if it is an issue with slack. Please let me know if there are any information that I can provide. Thank you for the quick response. I appreciate it.

seratch commented 1 year ago

@htran9 I cannot suggest anything further here. I'd suggest contacting our customer support agents via either /feedback in your Slack workspace or https://my.slack.com/help/requests/new instead. They may be able to check some Slack server-side logs for you.

htran9 commented 1 year ago

@seratch I will do that. Thank you!

github-actions[bot] commented 1 year ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] commented 1 year ago

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.