-
Notifications
You must be signed in to change notification settings - Fork 343
handle external fetch abort #880
base: master
Are you sure you want to change the base?
Conversation
@rezof: 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/ |
Codecov Report
@@ Coverage Diff @@
## master #880 +/- ##
=======================================
Coverage 95.21% 95.21%
=======================================
Files 22 22
Lines 1024 1024
Branches 109 109
=======================================
Hits 975 975
Misses 44 44
Partials 5 5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #880 +/- ##
==========================================
- Coverage 95.19% 95.14% -0.06%
==========================================
Files 22 22
Lines 1020 1029 +9
Branches 103 103
==========================================
+ Hits 971 979 +8
- Misses 44 45 +1
Partials 5 5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #880 +/- ##
=======================================
Coverage 95.21% 95.21%
=======================================
Files 22 22
Lines 1024 1024
Branches 109 109
=======================================
Hits 975 975
Misses 44 44
Partials 5 5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @rezof! While this change looks promising and makes sense, it would be great if you could add a test that shows this fixes apollographql/apollo-client#4150. That way we can make sure this is accounted for in future releases. Thanks again!
I've run into this issue. When will this change be implemented as it is holding my project back? |
When this test is implemented it will probably be pushed forward. If OP doesn't feel up to this, I'll try. |
@hwillson @JoviDeCroock test added |
Any news on this? |
// fetch was cancelled so its already been cleaned up in the unsubscribe | ||
if (err.name === 'AbortError') return; | ||
// exit if fetch was cancelled from the observer unsubscribing | ||
if (err.name === 'AbortError' && observer.closed) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you don't even need to check what type of error it is. If nobody is listening (observer.closed
), you can return here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, you shouldn't care what type of error it is. As long as someone is subscribed, they need to find out about this error, otherwise you're just leaving them hanging.
PS: As you probably figured out, the query deduplicator never finding out that the fetch was aborted is what's causing subsequent requests to hang.
FWIW, I think this PR makes sense, but it isn't a solution to the original issue. Using an AbortController to reach into the link stack and abort a request instead of unsubscribing breaks the abstraction. If you continue trying to work around it by putting in ifs and elses here and there, the code will become bloated and much more complicated, and you'll likely introduce more bugs and corner-cases along the way. I think the most logical way to go about this would be to make the promise returned by |
It would be nice of useLazyQuery() returned a "cancel" function. |
TODO: