Queries keep running after changing pages, inevitable errors of event handlers

Hi Retool Team,

I have a page with the following flow:

  • User clicks button
  • Button triggers workflow
  • Workflow triggers query
  • Query triggers the following script:
// Trigger both queries
const outputPromise = outputSummary.trigger();
const inputPromise = inputSummary.trigger();

// Wait for both queries to complete before running updateScenarioAI
Promise.all([outputPromise, inputPromise])
  .then(() => {
    const currentPage = url.href.split('/').pop();
    
    if (currentPage === "run_simulation") {
      // Both queries completed and page is run_simulation, so run updateScenarioAI
      updateScenarioAI.trigger();
    } else {
      console.log("updateScenarioAI not triggered because page is not run_simulation");
    }
  })
  .catch(error => {
    // Handle any errors that occurred in either query
    console.error("Error occurred:", error);
    utils.showNotification({
      title: "Error",
      description: "Failed to run one or more queries",
      type: "error"
    });
  });

Now, these are AI calls that often take between 15 to 30 seconds. The user already has available data from what the workflow returned, so he may decide to go back to another page and change parameters. However, the two AI queries are still running.

I have set up a js to give the user warning that they are still running and they can decide whether to go ahead and change page or not.

However, if they DO change page, the queries keep running, and then I get the error updateScenarioAI does not exist, have you deleted it or change the name.

I would like to know if:

  • It is possible to force queries to stop running, I haven't found a method for this, so I don't think it is possible
  • Is it possible to hide this notification somehow? As written above, the query is being triggered from a success event handler which is a script

Thanks!

Hi Miguel,
I can try to help you figure this out. You are correct that currently there is not way to force queries to stop running. I believe there is a feature request to our engineering for this, but I don't know how feasible this will be. But to help you solve the problem of the notification, I need to better understand your flow because I have not been able to replicate this notification on my end. Can you send me:

  1. a video of what happens in your app when you get this notice
  2. the json file from your app
  3. the json file from your workflow

You can export the json files like this:

Thanks!

Hey @MiguelOrtiz maybe I'm just missing something obvious, but could you not just have the option deselected in the GUI for that query which is "Show notification on success"?

1 Like

Hey AJ,

Well that's the thing, it is unticked, which makes it more annoying that it shows a notification.

@lindakwoo I will try to send the files tomorrow.

I don't think the workflow is relevant at this point, what I suggest you can do to replicate is the following:

  • create a query which as an AI query that generates text. Make it something a bit substantial so that it runs for about 15 to 20 s.
  • Add a success event handler that saves the results into a database
  • run the first AI query, and then change page when it is still running. Wait the time for AI query to run, and you should be seeing the notification.

image

Thanks
Miguel

@MiguelOrtiz,

Okay, yes please upload the json files here. Meanwhile I will try to reproduce your issue. So far I have been unable to reproduce your issue...

@MiguelOrtiz,
I am not able to reproduce your error. When I switch pages, it behaves just fine. If you get a chance, send me your json file.

1 Like