Re: [whatwg/fetch] Add option to reject the fetch promise automatically after a certain time elapsed (with no API for arbitrary aborts) (#179)

I had totally missed this issue, and wrote up some arguments in https://github.com/whatwg/fetch/issues/951.

I agree that the ergonomics are paramount (to cover the 90% case) because literally every `fetch` call should have an associated timeout. Python's `requests` docs cover it well:

> You can tell Requests to stop waiting for a response after a given number of seconds with the `timeout` parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely. [Source](https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts)

To eliminate the hanging failure case the `timeout` option needs to extend to cover `.json()` (and other body-reading promises) as well. (A lot of the existing examples that use promise-based timeouts do **not** handle this case and are buggy as written.)

This is similar to what Go does for their `Timeout` parameter:

> `Timeout` specifies a time limit for requests made by this `Client`. The timeout includes connection time, any redirects, and reading the response body. The timer remains running after `Get`, `Head`, `Post`, or `Do` return and will interrupt reading of the `Response.Body`. [Source](https://golang.org/pkg/net/http/#Client)

Thanks!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/179#issuecomment-541744174

Received on Monday, 14 October 2019 15:22:53 UTC