Page query error, not a valid query

Hey @Tess One more question pls.
I previously described that I'm using multiple apps, and everything seems to work fine. However, there's one intermittent bug that doesn’t always appear, and I can't track it down. Here’s the issue: Each app was imported as a page. In each app (prior to import), I had an SQL query called check_result. After importing all the apps, each of these queries was renumbered and given an additional index to avoid duplicates: check_result1, check_result2, and so on. At some point, when switching between pages, I encounter an error of this kind:
image
The query check_result is an SQL query that retrieves data from the backend using a known id. In this query, I store the id in a temporary variable. Data is assigned to this temporary variable after certain events occur, and the data is cleared from the temporary variable after check_result is successfully executed. I believe the error occurs when Retool tries to run all the queries when loading the page, and since the temporary variable has no value at that point, we get an error. Is there any way we can disable this check?

Hmm if it's due to the variable not having a value, you could disable the query conditionally on the Advanced tab of the query:

Today, I spent more time debugging the issue, and here’s what I noticed. When I navigate to Page 1, the error does not occur. The check_result query, which belongs to Page 1, seems to run successfully according to the log, even though the temporary variable is not defined. The error may appear when I navigate to another page, at which point I receive a notification that the check_result query is invalid, as shown in the picture.
I tried adding the condition you provided, but the situation hasn’t changed.
Here is an example in video:
https://app.screencastify.com/v3/watch/EceuyDOnMHurPdMEkPY0
@Tess

@Tess any ideas?
Maybe a separate topic should be created for this?

Hi @Dmitriy_Tulchinskiy,

I'll move this to a new topic :slightly_smiling_face:

Does the other page have a trigger for this query? Or, does the query get triggered when switching pages? If so, it might be worth making the query global, or duplicating it for the other page. If you aren't sure, can you check the state tab on Page 1 for the query to see how it is being triggered? The Console tab of the debug tools might also have some insight into how it is being triggered

Hey @Tess and thanks for your suggestions.
Today I spent another half a day trying to figure this out, and it seems I’ve identified some sort of dependency. This query is not global and is not related to page switching. Its purpose is to fetch the status of a task being executed on the backend.
Here’s the whole process:
I select the necessary parameters and click Submit. At this moment, a REST API request is sent with the parameters I selected, and in the response, I receive a task id from the backend, which I store in a temporary variable. Additionally, upon clicking Submit, a modal frame opens, and the Check_result query is reset.
In the Check_result query settings, there is an option enabled to run the query periodically, with the following condition for Disable query:
{{ (Check_result.data.state.filter((st) => st != 'completed' && st != 'failed').length === 0) }}
After saving the id in the variable, the Check_result query executes and continues to run periodically every N seconds until the Disable query condition is met. This allows me to periodically check the status of the task.
Today, I noticed that the error disappears if I uncheck the Run this query periodically option. However, this breaks my process because the Check_result query will run only once after the data is stored in the variable, and I need it to run periodically to monitor the status.

Hmm that's helpful! I see this error when I have a periodic query that triggers on a certain page. The error comes up whenever I navigate to another page. It seems like it still tries to run the periodic query once more even though I've switched pages. Is that the issue you're seeing?

I will report this to our team for a fix. In the meantime, I would make the query global

Hey @Tess
Yes, exactly. I observe this error after switching pages.

I converted this query to a global one and activated the "run periodically" flag, and the error no longer occurs. However, this isn't very convenient because this query triggers several others upon successful completion. This means that everything used in this query (e.g., variables) and everything it triggers must also become global.

Should I start converting all the queries on all the pages to global ones, or should I wait for a fix from the Retool team?

Hi @Dmitriy_Tulchinskiy Thanks for letting us know! I checked in with our team. I'm advocating for a fix within the next month or two :crossed_fingers: but I'm not able to guarantee a timeline yet