Skip to content

Feature request: Abort a request #167

Open

Description

@dmr

Is there a way to abort a request that was started by refetch?

We build a search component that queries "live" when the user enters characters.
Is there a way to stop the first request if the user entered something else?

Activity

  1. changed the title [-]Abort a request[/-] [+]Feature request: Abort a request[/+] on Mar 1, 2017
  2. ryanbrainard commented on Mar 6, 2017

    @ryanbrainard
    Contributor

    This came up before (can't find where at the moment), but we decided not to add cancellation functionality because the fetch API didn't have something for cancelling and looks like it still doesn't, so we'd really just end up only ignoring responses, which is already in effect what happens when we compare timestamps of the previous state. In other words, the fetch is still performed, but we only keep the response whose request was the started last. Once fetch has a way to cancel, I'd be open to exploring this more, but until then, what we have now is probably sufficient (please re-open if you think otherwise).

  3. dmr commented on Mar 6, 2017

    @dmr
    Author

    Thank you for the response. I unterstand your argument and think that it is a wise choice to wait for fetch.

    Unfortunately I still have the use case to implement so maybe I'll explore other options.

  4. tjokimie commented on Nov 7, 2018

    @tjokimie

    Fetch now supports AbortController which can be used to abort requests, see https://robwise.github.io/blog/cancel-whatwg-fetch-requests-in-react for example.

  5. ryanbrainard commented on Nov 9, 2018

    @ryanbrainard
    Contributor

    @tjokimie Thanks for finding that. I'll re-open this, but no promises on getting to it any time soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions