bolt-js: client.views.update does not update the modal

Description

Describe your issue here. I’m trying to update a modal view after a user has selected an item from an interactive static select. In the action handler for that element, I update the modal with a loader view, while I rebuild the new view and call client.views.update with the new view. Sometimes while changing the item in static select the view gets stuck at loader view and doesn’t get updated with the new view.

app.action("static-select-recognition-action", async({ body, context, ack}) =>{
  await ack();
  try
  {
    let value = body.actions[0].selected_option.value;
    let { id, name } = JSON.parse(value);
    let { view_id, peer_to_peer_rewards } = teamUserDataMap[body.user.id];
    const recognition = {
      text: {
        type: "plain_text",
        text: name,
        emoji: true,
      },
      value: name,
    };
    const extraBlocks = [
      {
        type: "section",
        text: {
          type: "mrkdwn",
          text: "*Recognition*",
        },
        accessory: {
          type: "static_select",
          placeholder: {
            type: "plain_text",
            text: "Select an item",
            emoji: true,
          },
          options: [recognition],
          initial_option: recognition,
          action_id: "static-select-recognition-action",
        },
      },
    ];
  
    await app.client.views.update({
      view_id: view_id,
      token: context.botToken,
      trigger_id: body.trigger_id,
      view: loaderView.view("loader", extraBlocks),
    })
       const view = await ptpModal.view(
         peer_to_peer_rewards,
         value,
         body.response_url,
         id
       );

       await app.client.views.update({
         view_id: view_id,
         token: context.botToken,
         trigger_id: body.trigger_id,
         view: view,
       });
      

  } catch (error)
  {
    console.log("static-select-recognition-action", error);
  }
})

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

@santhinisj I know it’s been quite a while but did you manage to find out the root cause of this. I’m having the same problem. There seems to be some kind of delay between the open view and the update view. The Slack server responded with a not_found error but I could see the view_id in the logs. At my wit’s end because I don’t know what’s wrong here. This doesn’t occur at my local environment either.

Thanks for sharing the video. Indeed, the views.update seems to be failing for some reason. However, as this SDK maintainers, the only advice that we can provide is to check the logs/metrics related to your deployed application.

If you observe delays or misbehavior on the Slack server-side, could you contact our customer support agents from /feedback in your Slack workspace or https://my.slack.com/help/requests/new? They can do deeper investigation with the Slack server-side logs/metrics for you.

Hey, I tried by adding hash from the response of the first view to update the next view. This block of code gets executed whenever I am trying to change the static menu in a modal.

let res = await app.client.views.update({
        view_id: view_id,
        hash: hash,
        token: context.botToken,
        view: loaderView.view("loader", extraBlocks),
      });

      const view = await getView();

      let res1 = await app.client.views.update({
         view_id: view_id,
        hash: res.view.hash,
        token: context.botToken,
        view: view,
      });

But still, this issue persists.

You can reproduce this issue with:

  1. Open a modal with multiple select static menus
  2. Select an option from the first select menu
  3. Receive the action with Bolt
  4. Update the view with a view first, then update it again. But modal doesn’t freeze on first view all the time.