Open mihirkothari25 opened 1 day ago
Hi @mihirkothari25! Thanks for raising this. A quick search internally reveals that this is not the first time that we've heard this issue from folks, but it's not immediately clear to me what the resolution is (if it even exists). I'll do a bit more digging and get back to you with more information (and hopefully a solution) next week.
I created a sample custom function to demonstrate the issue we are seeing - https://github.com/mihirkothari25/bolt-js-getting-started-app. It's adapted from the sample starter app. I run ngrok and serverless-offline to run the app locally and point the event subscription URL in the slack app to the ngrok URL. I see that even after responding immediately from the function if the next interaction with Slack takes more than 3 seconds, the token_revoked error is thrown. If an API call takes longer than 3 seconds after the function has responded the first time, there will be a
token_revoked
error on the next complete or whatever slack function is being called.In the real world scenario -
/slack/events
endpoint configured in API Gateway.complete
, and it results in atoken_revoked
error.To mitigate this issue, we tried to immediately respond after the lambda function starts execution. As soon as the lambda function starts executing, it would post an ephemeral message back to the user however, when the AWS Lambda cold starts, that takes too long, and the same error is encountered. If the AWS Lambda is warm, the error is less frequent.
My sample app impersonates the API call by just doing a sleep timeout. It also impersonates the AWS infrastructure by using serverless-offline.
@slack/bolt
version3.22.0
Your
App
and Receiver ConfigurationLink to Application code - https://github.com/mihirkothari25/bolt-js-getting-started-app/blob/main/app.js
Using the
AwsLambdaReceiver
Node.js runtime version
v21.7.3
Steps to reproduce:
https://github.com/mihirkothari25/bolt-js-getting-started-app/tree/main - forked and adapted starter app. Run
npm install
to install dependencies.ngrok http 3000
npm run serverless
Expected result:
Slack should respond initially that it is executing the request and then respond with the result once it is done.
Actual result:
If the sleep is longer than 3 seconds, the function ends with the token_revoked error. This is despite responding immediately from the function and then sleeping for longer than 3 seconds.
Is the expectation that the function should keep pushing heartbeats to slack while it is finishing the execution of underlying API calls?
These are the errors -