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

Timeout #147

Open
justfede opened this issue Sep 15, 2017 · 3 comments
Open

Timeout #147

justfede opened this issue Sep 15, 2017 · 3 comments

Comments

@justfede
Copy link

Hi guys? There's anyway to set a timeout? (Without use a setTimeout() and throw some error manually)

PS: I'm using react.

Thanks!

@OpenDog
Copy link

OpenDog commented Jul 18, 2018

Nada?

@jimmywarting
Copy link

jimmywarting commented Jan 28, 2019

possible duplicate of #48? so can this be closed?

Also a timeout isn't the right solution for aborting a fetch request as it will continue to download if you wrap the fetch promise with a timeout race.

The right solution is to use abortcontroller

const controller = new AbortController()
const signal = controller.signal

setTimeout(() => { 
  controller.abort()
}, 1000)

fetch(url, { signal })

@ianstormtaylor
Copy link

FWIW, I've opened an issue whatwg/fetch#951 with a proposal for a timeout option that solves 90% of use cases, in case anyone's interested. I think it's super important to add to make sure calls to fetch (or res.json()) don't hang indefinitely.

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

4 participants