Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomeightyeight/d3564fb9d68194673fa3d7373f28a97c to your computer and use it in GitHub Desktop.
Save tomeightyeight/d3564fb9d68194673fa3d7373f28a97c to your computer and use it in GitHub Desktop.
Fetch Problems
fetch has yet to provide a standard way of aborting a request. Therefore, there's no way to implement connection timeout. (#27)
fetch has failed to provide an API to set response timeout. (#20)
...which means that you'll have to wait until the end of the response or the occurrence of a network error.
...or, use setTimeout or Promise.race to manually reject the returned promise if you need a timeout. And it has a tiny side effect (#175):
mislav commented on 29 Jul 2015
Also note that with the above implementation, even if the timeout happens, the original request won't be aborted because we don't have an API to abort fetch requests. Instead, the request will complete in the background but its response will get discarded.
See the comments of this blog post. And I'm totally agree with the following one:
J W
Although the standard loosely talks about timeout’s, they never explain as to how you would specify one either. Unfortunately, a complete deal breaker for any use cases that I would use it for.
March 17th, 2015 at 15:02
Notice that all the above opinions are based on fetch (or its browser polyfill), not node-fetch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment