Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useQuery pollInterval with cache-and-network doesn't stop to make requests after unmounting a component #9431

Closed
hsk-kr opened this issue Feb 15, 2022 · 11 comments · Fixed by #11837
Assignees
Labels
🔍 investigate Investigate further

Comments

@hsk-kr
Copy link

hsk-kr commented Feb 15, 2022

Intended outcome: Make a request every pollInterval ms and stop making requests after unmounting the component.

Actual outcome: Make two requests every pollIntervalms and doesn't stop and make a request every pollIntervalms after unmounting the component

How to reproduce the issue:

const { data, error } = useQuery(ANY_QUERY, {
    fetchPolicy: "cache-and-network",
    pollInterval: 1000,
  });

It works with other fetchPolicy but it doesn't work with cache-and-network.

Versions

^3.5.8

@hsk-kr hsk-kr changed the title pollInterval with cache-and-network doesn't stop to make requests after unmounting a component useQuery pollInterval with cache-and-network doesn't stop to make requests after unmounting a component Feb 15, 2022
@bignimbus bignimbus added the 🔍 investigate Investigate further label Dec 14, 2022
@arvindell
Copy link

Have the same problem

@jerelmiller jerelmiller added the 🏓 awaiting-team-response requires input from the apollo team label Dec 19, 2022
@nikgraf
Copy link

nikgraf commented Mar 15, 2023

Ran into the same issue

@AlekseyMalakhov
Copy link

Problem still exists

@Draiken
Copy link

Draiken commented Nov 30, 2023

We are hitting this issue but it seems like it's only in strict-mode. When in production it doesn't seem to keep the queries running after unmounting.

We are on version 3.8.7

@MilanJimi
Copy link

Same here.

@rossvz
Copy link

rossvz commented May 3, 2024

Ran into this as well. In our case it was something like

 { isEnabled ? (<ComponentA/> ) : (<ComponentB/>) }

and each component had a pollInterval with the cache-and-network policy. When isEnabled changes and we render a different component, the polling for the other component was still running. Changing the policy to network-only resolved the issue.

@jerelmiller
Copy link
Member

Hey all 👋

Would anybody be able to share a minimal reproduction of this issue? I've attempted to reproduce this with our tests but have been unsuccessful. Both strict mode and non-strict mode seem to stop polling as expected when the component unmounts.

Take a look at https://github.com/apollographql/apollo-client/compare/jerel/cache-and-network-polling?expand=1 for my attempt to reproduce this. Any help would be appreciated recreating the issue.

@jerelmiller jerelmiller added 🏓 awaiting-contributor-response requires input from a contributor and removed 🏓 awaiting-team-response requires input from the apollo team labels May 3, 2024
@dylanwulf
Copy link
Contributor

Possibly related to my issue #11750 which does have a reproduction

@jerelmiller
Copy link
Member

Awesome, thanks @dylanwulf!

Copy link
Contributor

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.

@jerelmiller jerelmiller self-assigned this May 13, 2024
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔍 investigate Investigate further
Projects
None yet
10 participants