You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstAgentReportsProvider: React.FunctionComponent<PropsWithChildren<unknown>>=({children})=>{// If authentication is enabled but there is no logged-in user, skip the// query.letskip=false;if(appCfg.AuthEnabled&&!appCfg.User){skip=true;}const{data: reportRes}=useQuery(GET_AGENT_REPORTS,{pollInterval: appCfg.AgentsPollIntervalMillis,fetchPolicy: "no-cache",skip: skip,});
...
The intention is to poll this query while the user is logged in, and stop polling it when the user logs out. This doesn't seem to work: if skip is ever false, network requests continue to be issued even after skip turns to true later.
Note that all I see are the network requests still being issued. I don't know if the component re-renders with new results from the query.
I have also tried switching the pollInterval argument to undefined once skip is set to true; it did not help.
A few months ago I had found a perhaps similar bug with useSuspenseQuery (#11768), in case that provides inspiration.
Link to Reproduction
N/A
Reproduction Steps
No response
@apollo/client version
3.9.11, 3.11.5
The text was updated successfully, but these errors were encountered:
andreimatei
changed the title
useQuery polling query does not stop issuing network requests when the skip argument switches from true to false
useQuery polling query does not stop issuing network requests when the skip argument switches from false to true
Sep 16, 2024
I had typed this issue backwards, claiming that the problem is when switching skip from true -> false. It's the other way around -- the problem is when switch false -> true. I've edited the post above to make it sane.
I have also tried switching the pollInterval argument to undefined once skip is set to true; it did not help.
Setting pollInterval to a really high number does help, though, fwiw.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.
Issue Description
Consider the following code:
The intention is to poll this query while the user is logged in, and stop polling it when the user logs out. This doesn't seem to work: if
skip
is everfalse
, network requests continue to be issued even afterskip
turns totrue
later.Note that all I see are the network requests still being issued. I don't know if the component re-renders with new results from the query.
I have also tried switching the
pollInterval
argument toundefined
onceskip
is set totrue
; it did not help.A few months ago I had found a perhaps similar bug with
useSuspenseQuery
(#11768), in case that provides inspiration.Link to Reproduction
N/A
Reproduction Steps
No response
@apollo/client
version3.9.11, 3.11.5
The text was updated successfully, but these errors were encountered: