Skip to content
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

Properly support the signal fetch option #209

Closed
jaydenseric opened this issue Jul 22, 2020 · 0 comments
Closed

Properly support the signal fetch option #209

jaydenseric opened this issue Jul 22, 2020 · 0 comments
Labels

Comments

@jaydenseric
Copy link
Owner

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:

https://github.com/apollographql/apollo-client/blob/3c56a1d7a696ed63b2d3681aab0c23b8ea0831db/src/link/http/createHttpLink.ts#L89

If the user supplies a signal that aborts the fetch, a return is used that causes the observable to never progress:

https://github.com/apollographql/apollo-client/blob/3c56a1d7a696ed63b2d3681aab0c23b8ea0831db/src/link/http/createHttpLink.ts#L134-L135

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant