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

@Pauan why would you want it to include `response.json()`? I don't think including it gains you anything. 

The way "timeout" is used in most libraries is pretty clear: if you haven't received a response in that amount of time then it's considered failed. And it's defined that way because that's how it's useful to guard against the uncertainty of the network. 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?

@Pauan @taralx As for the `withTimeout` helpers, I agree that those _can_ be created. Thanks for the examples! I just think timeouts are such a common case (so much so that arguably you're not writing "complete" code if you aren't including a timeout). And that for common cases like that the API should help you do the right thing, which in this case would be:

```
fetch(url, {
  timeout: 5000
})
```

This seems like at least one thing XHR got right? `xhr.timeout = 500`.

-- 
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-541039815

Received on Friday, 11 October 2019 12:16:40 UTC