W
Wasp7mo ago
Sonjho

Operations restarts everytime i alt-tab to the window

I've used opensaas template as starter point and altered it a lot, but operations are pretty much the same, they are actually just select some rows using prisma queries do you know how i can fix this issue or at least what i should read?
5 Replies
kapa.ai
kapa.ai7mo ago
Hi @Sonjho. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. However, it seems like you're experiencing an issue with continuous recompiling. A similar issue was discussed in a Discord support thread (https://discord.com/channels/686873244791210014/1221353318845120542), where a user reported their project recompiling over and over again after making changes to the LandingPage.tsx file in the opensaas template. Unfortunately, the solution to this issue was not provided in the knowledge sources I have. For your issue, it might be helpful to check if there are any errors in your console or if there are any changes in your code that might be causing this. If you're unable to find the cause, you might want to consider sharing more details about your issue, such as any error messages you're seeing and the specific changes you've made to your code. You can also refer to the Wasp documentation (https://wasp-lang.dev/docs/general/cli#overview) for more information on how to use the Wasp CLI, which might help you troubleshoot your issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sonjho, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsos7mo ago
Do you mean to say that operations are triggered and data is re-fetched every time you get back to your window? So you are probably using operations on client via useQuery, right? It is a default option for useQuery to invalidate its cache upon window focus (which is alt-tab in your case), therefore triggering the operations to run again. You can confgiure that though, by configuring query client config. Here are our docs on it: https://wasp-lang.dev/docs/project/client-config#overriding-default-behaviour-for-queries
Sonjho
SonjhoOP7mo ago
@martinsos thank you for response! it is exactly what i need. I've managed to configure global rule using setupFn in wasp config, but i didn't understand how to configure single query, tryied to read both wasp and query client docks but no luck. can you help with this one as well, please?
Vinny (@Wasp)
Vinny (@Wasp)7mo ago
if you don't want a single, specific query to fetch automatically, you can do this:
const { data: tasks, isLoading, error, refetch } = useQuery(getTasks, undefined, { enabled: false });

return (
<div>
<button onClick={() => refetch()}>Fetch Tasks</button>
//....
const { data: tasks, isLoading, error, refetch } = useQuery(getTasks, undefined, { enabled: false });

return (
<div>
<button onClick={() => refetch()}>Fetch Tasks</button>
//....
this will disable the fetch until you click the button
martinsos
martinsos7mo ago
@Sonjho does this help? https://tanstack.com/query/v4/docs/framework/react/guides/window-focus-refetching . We are still on version 4, that is important, will be upgrading in the following months likely. So based on this, you would do something like what @Vinny (@Wasp) said above, but instead of enabled: false, which disables it completely, you could do refetchOnWindowFocus: false.
Window Focus Refetching | TanStack Query React Docs
If a user leaves your application and returns and the query data is stale, TanStack Query automatically requests fresh data for you in the background. You can disable this globally or per-query using the refetchOnWindowFocus option: Disabling Globally
Want results from more Discord servers?
Add your server