bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

Ack call timeout

Open mrafiqi21 opened this issue 4 years ago • 6 comments

Description

Describe your issue here. It is mentioned in the api doc that a method should be returned immediately with ack() call to avoid timeout. My usecase is to fetch a file from slack and upload the file in a cloud server and return some information like the hosted url. This takes more than the 3 second limit and I can't move to the next view. Any suggestions on how I could achieve something like this?

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

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

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

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] 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:

node version:

OS version(s):

Steps to reproduce:

1. 2. 3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

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

mrafiqi21 avatar Mar 03 '22 10:03 mrafiqi21

Hi @mrafiqi21, thanks for asking the question!

If your goal is to asynchronously post a message, you can use respond() utility to do so after ack(). Refer to https://slack.dev/bolt-js/concepts#action-respond for more details:

If your use case is to handle data submission from a modal, check my suggestion at https://github.com/slackapi/bolt-python/issues/481#issuecomment-930038349 (displaying "Now loading" page first, and then calling views.update API method when the result is ready)

I hope this helps.

seratch avatar Mar 03 '22 10:03 seratch

@seratch Hey, my usecase is handle data submission from a modal.

const uploadFileModalCallback = async ({ ack, view, body, client }) => {
  const providedValues = view.state.values;
  await ack({
    response_action: 'update',
    view: modals.loadingPage()
  });  

//Fetching file from slack and uploading it to cloud, and waiting for the response which has the URL (Takes more than 3 seconds)

client.views.update({
       view_id : ??
       view: modals.createProfileModal(ReponseURL)
  })

Are you suggesting something like this? If yes, what should be the view_id for the view update call?

mrafiqi21 avatar Mar 03 '22 11:03 mrafiqi21

@mrafiqi21 Yes, I am. As for the view_id, you can use view.id for it.

seratch avatar Mar 03 '22 11:03 seratch

Thanks @seratch, works fine. Just one question, can we disable the close button in the loading page modal because it risks the user closing the loading view?

mrafiqi21 avatar Mar 03 '22 11:03 mrafiqi21

Unfortunately, there is no way to do so. The only thing that I can suggest is to receive view_closed events to know the situation. https://api.slack.com/reference/interaction-payloads/views#view_closed

Is everything clear now?

seratch avatar Mar 03 '22 11:03 seratch

Yes, thank you so much. Closing the issue.

mrafiqi21 avatar Mar 03 '22 11:03 mrafiqi21