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

I don't think the code example comparisons are fair. Here is something more realistic:

```js
const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);

fetch('https://example.com', { signal: controller.signal });
```

or, if you have a tiny utility library

```js
fetch('https://example.com', { signal: timeoutSignal(5000) });
```

compared to

```js
fetch('https://example.com', { timeout: 5000 });
```

If anything, it might make sense to add something like `AbortSignal.timeout(5000)`.

But if you are making a purely ergonomic argument, it's best not to exaggerate your point with unnecessary `const signal =` or `clearTimeout()` lines, or to ignore the potential for libraries to allow saving yourself 2 lines of code.

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

Received on Saturday, 12 October 2019 23:39:49 UTC