-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Having multiple polling queries on the same QueryManager causes setInterval leak #248
Comments
@jbaxleyiii - I think the polling state needs to move to the individual query instead of on the query manager? Would it be better stored on the query handle in some way, perhaps as described here #194? |
@jbaxleyiii Any update on this issue? It's currently blocking us from using Apollo client in production. If you want, @Poincare could also look into it. |
I tried a work-around for this by making my own timer and using |
Sure, I'll look into this in detail tomorrow and hopefully make some headway on some kind of fix. |
I think there is another subtlety to be aware of here. If your query takes LONGER than the polling interval, it seems the query will re-fire before you receive any results, and even when the original request completes, the data never gets propagated because another (identical) query is already in-flight. I don't know if the fix for this would be in |
I think that issue is currently mentioned in the code as something to fix. It seems the polling structure requires some pretty significant changes so that (1) polling doesn't leak (2) we can keep track of the queries that have been sent to the server (probably by query id) and don't re-fire the same query again. I think fixing this issue is actually pretty intimately connected to the batching over HTTP since I've been building a tick-based scheduler-like system for that anyway. Hopefully, that will make it easier to resolve this issue and others that involve the current polling system. |
@timbotnik while @Poincare fixes the polling setup, I think I fixed apollographql/react-apollo#61 with |
I think for now it's fine to keep polling even if some query is still in flight, but we should fix the bug where the UI doesn't update when a query returns if there's still some polling query in flight. |
@Poincare @jbaxleyiii Now that apollographql/react-apollo#61 is fixed, I have a viable work-around for the polling issue, which is to manage my own timer per component and call |
Great to hear. I have a fix working for the polling timer issue but I'm still working on the unit test that should be able to reproduce this issue. I think it will be valuable to have this unit test working since the complexity of the polling mechanism will only increase and having a template to test the polling queries will be helpful. |
I am on apollo-client 1.4.0 and I think I'm experiencing this issue as described above. I am introducing React into an existing codebase so have multiple top-level components. One of the components I am mounting fetches data via two separately I'm not sure how to debug this really as I'm only a day into my experience with Apollo and I may just be doing something obviously wrong. |
I've encountered the same issue on react-apollo@1.4.15. I am using old ejected create-react-app (with webpack@1) and making requests through webpack proxy. I solve this problem only by this way: Do not use webpack proxy if you have some polling components, just send graphql requests directly to the server. In my case, the time of page reloading increased by multiple times after that. Maybe this issue also can be solved through apollo-link-retry in Apollo v2. I've recorded a snapshot just in case. |
I discovered this one via a React component (with Apollo connect container) that had multiple polling queries. Each time I unmounted & mounted the component, I would get a polling leak, as evidenced by increasingly frequent HTTP requests to my
/graphql
endpoint.I put some console logging in this zone https://github.com/apollostack/apollo-client/blob/master/src/QueryManager.ts#L426-L455, like this:
I mounted & unmounted the component twice, and the component sets up 3 polling queries on every mount. Here's the result:
As you can see it looks like we have lost (overwritten?) our references to timers 94, 128, 146, & 147.
The text was updated successfully, but these errors were encountered: