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

Has there been any talk of improving the timeout ergonomics? Now that the whole `AbortController` thing has been hashed out?

It seems like… given the nature of HTTP/TCP, no request is ever guaranteed to respond to you, and the agreed upon solution for this is to use timeouts. Such that pretty much every request you make should have some form of timeout. (Just like every request you make should account for network errors.)

Given that, it seems problematic that it takes…

```js
const controller = new AbortController();
const signal = controller.signal;
const fetchPromise = fetch(url, {signal});
const timeoutId = setTimeout(() => controller.abort(), 5000);
const response = await fetchPromise;
clearTimeout(timeoutId);
```

…to properly send a request with a timeout.

Has anyone discussed adding a `timeout: number` shorthand option? (It was mentioned in the very first comment back in 2015, but it seems like the UX might have gotten lost in the quest for true cancellation?)

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

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

Received on Friday, 11 October 2019 02:38:23 UTC