Re: [whatwg/fetch] Add a `timeout` option (#951)

@ianstormtaylor The problem with your solution is that it only covers the common case but falls apart in even slightly uncommon cases. For example:

```js
const res = await fetch('https://example.com', { timeout: 10000 });

const shouldFetch = await checkSomething(res);
if (shouldFetch) {
    return await res.json();
}
```

In this case the timeout will cover only the headers, not the body. This is very surprising and unexpected, it will lead to subtle bugs that are hard to find and debug.

That's why I said this issue is tricky, and it's why I still advocate for [explicitly indicating the scope of the timeout](https://github.com/whatwg/fetch/issues/20#issuecomment-540917173). This makes it absolutely 100% clear what is covered by the timeout, so it prevents bugs. And the code is short, so it's not a big burden on the developer.

So if you're going to have a `timeout` property, it cannot have ambiguous behavior, it must have very clear behavior. For example, `timeout` could be specified so that it *always* applies to the body, and so if you don't want that then you'll need to manually use `AbortController`.

-- 
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/951#issuecomment-541374135

Received on Sunday, 13 October 2019 00:44:53 UTC