slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno

Home Page:https://api.slack.com/automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange Function Success / Failure Behavior

anthonygualandri opened this issue · comments

The deno-slack versions

Deno runtime version

OS info

Steps to reproduce

Getting kind of strange function behavior. When I run a function that calls an external api from inside of it, if the number of records returned by the call is somewhat large then the slack debug function output looks like this:

functions.completeSuccess request payload: { "outputs": {}, "function_execution_id": "Fx06LTHRJH9N" } functions.completeSuccess response payload: { ok: false, error: "token_revoked" }

But when I reduce the size of the payload returned it outputs this:

functions.completeSuccess request payload: { "outputs": {}, "function_execution_id": "Fx06L1U0AV9T" } functions.completeSuccess response payload: { ok: true }

Any idea what’s going on? What does the size of the payload have to do with whether or not slack accepts the slack token being used in the function call? Is there a timeout on functions that I’m not aware of? If so then payload response is not all that clear in order to understand what’s going on. Thanks for any light you can shed on this.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@anthonygualandri -Hm, so that token_revoked error tells me Slack thinks that the step has already finished by the time you make the functions.completeSuccess call. Let me do a little asking around on this one.

Thanks @srajiang. That functions.completeSuccess call is not being explicitly made by me in the code but by having the .env file flagged with SLACK_DEBUG=true. Just wanted to make sure that part was clear in case it has something to do with the implementation of that flag.

I am also see the token_revoked error with even the simple "hello world" app deployed locally.

I really think it has to do with the restriction that your function has to complete in 3 seconds, because that's what Slack has decided is the limit for local apps (vs deployed apps, which have a 15-second limit).

Thanks for the context @anthonygualandri - so it's just a log, and you're not explicitly trying to complete the function. This does sound like the timeout issue @mcsescott refers to.

Alright, there's some ongoing internal discussion about the 3s vs. 15s timeouts, I don't have anything new to share on that front and so my best guess is that at the moment, this local vs. deployed app timeout distinction is sticking around.

@anthonygualandri are you able to to confirm whether you see this error in your deployed app? (Writing this, I know this is a little strange, given that you should be able to test under the same conditions you're deploying in 😞 ). But, if you ARE in a position to confirm that it doesn't happen in the deploy scenario, then that's informative.

I am also see the token_revoked error with even the simple "hello world" app deployed locally.

@mcsescott could you share the code and configuration of the "hello world" app, I don't seem to be able to reproduce this with the hello world sample project

My steps:

  1. slack create test-hello-world -t https://github.com/slack-samples/deno-hello-world
  2. cd test-hello-world/
  3. slack run + create the trigger
  4. test in a workspace

@WilliamBergamin

There is no logging for the app that can give you the token revoked message, but it appears I am getting hit by the 3-second limit that Slack has imposed on locally developed apps, which is a continual problem for development. 👎

test-hello-world.txt

Yess the 3-second limit has been a limiting feature for others as well, the simplest work around for this is to use some sort of message broker like amazon mq to offload long running processes to workers, allowing the request to be response within the timeout limit