Skip to content

Properly support the signal fetch option #209

@jaydenseric

Description

@jaydenseric

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions