-
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
Unsubscribing from a query does not abort network requests #6985
Comments
I've seen the same bug. Here is a sandbox with @apollo/link 3.2.1: https://codesandbox.io/s/apollo-client-321-unsubscribe-h76nh The unsubscribe method gets never called in 3.2.1 and thus not aborting the http request. I've digged through the code and I think the problem is the following:
Would be great if someone could have a look at this. |
I actually submitted an issue about this over a year ago (#4955) and unfortunately it seems like it hasn't been resolved yet |
Oh, did not find your ticket. I think this should get way more attention. It's an ugly bug with an easy fix. |
When there are multiple observers subscribed to a Concast, messages should be delivered in the order the observers were added. The shadowObservers approach notified any cleanup observers after any normal observers, potentially reordereding message delivery. I'm not sure that reordering was necessarily "wrong," but it would be a very tricky problem to track down for anyone who might be affected by it. However, if any other non-cleanup observers have been added, and the last observer removed is a cleanup observer, then we should unsubscribe from this.sub, to preserve the fix for apollographql#6985.
When there are multiple observers subscribed to a Concast, messages should be delivered in the order the observers were added. The shadowObservers approach notified any cleanup observers after any normal observers, potentially reordereding message delivery. I'm not sure that reordering was necessarily "wrong," but it would be a very tricky problem to track down for anyone who might be affected by it. However, if any other non-cleanup observers have been added, and the last observer removed is a cleanup observer, then we should unsubscribe from this.sub, to preserve the fix for apollographql#6985.
…leanup2 Fix cleanup observer blocking unsubscribe, part 2. Fixes #6985.
I believe that part of the issue will be fixed in |
Aborting network requests used to work in apollo-client 2.5.1, where they could be cancelled by either unmounting a component or unsubscribing from an observable query.
I skimmed through the code and it seems that if the browser supports
AbortController
, the http link should cancel pending requests when you unsubscribe from it, but it never does 🤷Intended outcome:
When you subscribe to a query and later unsubscribe from it, while the network request is still in-flight, it should be aborted.
Actual outcome:
Network requests are never aborted.
Versions
npmPackages:
@apollo/client: ^3.1.3 => 3.1.3
The text was updated successfully, but these errors were encountered: