Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Fix useQuery keeps polling bug from #3272 #3273

Merged
merged 10 commits into from Aug 5, 2019
Merged

Fix useQuery keeps polling bug from #3272 #3273

merged 10 commits into from Aug 5, 2019

Conversation

dqunbp
Copy link
Contributor

@dqunbp dqunbp commented Jul 24, 2019

Fixes #3272

- update add link prop to the MockedProvider
- add test that fails when component unmounted
@apollo-cla
Copy link

@dqunbp: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@dqunbp dqunbp mentioned this pull request Jul 24, 2019
@damiangreen
Copy link

is the agreemetn signed? this causes apps to completelyt stop working in Chrome as it continues to fire off polling requests for components that no longer existing.

@dqunbp
Copy link
Contributor Author

dqunbp commented Jul 26, 2019

@damiangreen It's of course signed

@damiangreen
Copy link

@dqunbp nice work i hope it gets merged soon

@dqunbp dqunbp changed the title Fix bug from issue 3272 Fix useQuery keeps polling bug from #3272 Aug 1, 2019
@tgroshon
Copy link

tgroshon commented Aug 2, 2019

I am really excited for this PR to be merged. Could you help me understand why setTimeout() is necessary in the effect cleanup?

return () => {setTimeout(() => queryData.cleanup())} instead of return () => queryData.cleanup()?

Why is the setTimeout() necessary?

@filipemonteiroth
Copy link

I am really excited for this PR to be merged. Could you help me understand why setTimeout() is necessary in the effect cleanup?

return () => {setTimeout(() => queryData.cleanup())} instead of return () => queryData.cleanup()?

Why is the setTimeout() necessary?

I think the idea is taking this execution from the main thread and let the browser queue and do that when it's best for it. maybe?! 🤔

@tgroshon
Copy link

tgroshon commented Aug 2, 2019

Maybe, but React defers running useEffect (and cleanup) until after the browser has painted, so doing extra work is less of a problem. So if that is the reason, is it necessary?

@dqunbp
Copy link
Contributor Author

dqunbp commented Aug 4, 2019

Because inside QueryData, setTimeout is used:

setTimeout(() => {
      this.currentObservable.query!.resetQueryStoreErrors();
    });

This code breaks without it

@tgroshon
Copy link

tgroshon commented Aug 4, 2019 via email

@hwillson hwillson self-assigned this Aug 5, 2019
@hwillson hwillson added this to the Release 3.0 milestone Aug 5, 2019
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for tackling this @dqunbp!

These changes will let us avoid the extra `setTimeout` call
in the cleanup `useEffect`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useQuery keeps polling
6 participants