-
-
Notifications
You must be signed in to change notification settings - Fork 153
Properly support the signal fetch option #209
Description
Initialy brought up in #204 (comment) .
Apollo Client with HttpLink doesn’t support aborting queries via standard fetch and AbortControler signals. You're only supposed to somehow use the Apollo Client subscription system:
apollographql/apollo-client#4150
Apollo’s HttpLink documentation for the option fetchOptions doesn't mention that the standard signal fetch option should not be used:
https://www.apollographql.com/docs/link/links/http/#options
Although the HttpLink code defers to a user configured signal, it will conflict with the way Apollo Client works:
If the user supplies a signal that aborts the fetch, a return is used that causes the observable to never progress:
In that situation, if you did await apolloClient.query( it would never resolve; Node.js detects the promise is stuck in a pending status and skips the rest of your code without an error.
Previously we closely replicated the HttpLink logic for all this, but once we have tests we can fix this bug properly.
There should be a distinction between an a fetch AbortError before, vs after, the observer cleanup. Such an error before the cleanup function runs should be treated like any other fetch error. After cleanup begins, it will be ignored because there is nothing subscribed to errors anymore anyway.