Closed wheresrhys closed 2 years ago
Thanks, yeah, this can be closed. We still have #179 and #180 for the more complicated scenarios.
AbortSignal.timeout
looks great, thanks to everyone who worked on speccing and implementing this! (whatwg/dom#1032, w3ctag/design-reviews#711)
// Fetch the URL, cancelling after 8 seconds
fetch(url, { signal: AbortSignal.timeout(8000) });
Apparently available in Firefox 100 and [Chrome 103 beta](https://blog.chromium.org/2022/05/chrome-103-beta-early-navigation-hints.html#:~:text=abortsignal.timeout()%20static%20method)!!
And in Firefox 100 😉
Thanks, wasn't aware about this, updated my post above!
Most ajax libraries and xhr itself offer a convenient way to set a timeout for a request. Adding
timeout
to the properties accepted in the options object therefore seems like a sensible addition to fetch.https://github.com/github/fetch/pull/68