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

Feature request: Abort a request #167

Open
dmr opened this issue Mar 1, 2017 · 4 comments
Open

Feature request: Abort a request #167

dmr opened this issue Mar 1, 2017 · 4 comments

Comments

@dmr
Copy link

dmr commented Mar 1, 2017

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?

@dmr dmr changed the title Abort a request Feature request: Abort a request Mar 1, 2017
@ryanbrainard
Copy link
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).

@dmr
Copy link
Author

dmr commented Mar 6, 2017

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.

@tjokimie
Copy link

tjokimie commented Nov 7, 2018

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.

@ryanbrainard
Copy link
Contributor

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

@ryanbrainard ryanbrainard reopened this Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants