Re: [whatwg/fetch] Add timeout option (#20)

> @ianstormtaylor But if you're about to call response.json that means you've already received a response. There's no need to have the timeout extend to that part of the code because there's no longer any uncertainty there?

That's not true: when `fetch` resolves that just means that the headers have been received, the body has *not* been received.

So when you fetch the body (using `response.json()` or `response.text()` or similar), it can fail. So you need the timeout to cover that case as well.

> And that for common cases like that the API should help you do the right thing

That's my point: the "right thing" in most cases is that the timeout should extend to retrieving the body. That's very easy to do if you're using `with_timeout`, but tricky to define if `timeout` is native to `fetch`.

> This seems like at least one thing XHR got right?

XHR completes when the *body* is received. `fetch` completes when the *headers* are received. They're not the same thing.

I agree that XHR's behavior is correct, which is why the timeout for `fetch` must include fetching the body. That's what `with_timeout` does.

-- 
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/20#issuecomment-541270938

Received on Saturday, 12 October 2019 01:47:22 UTC