- From: Kornel <notifications@github.com>
- Date: Mon, 14 Dec 2015 07:09:47 -0800
- To: whatwg/fetch <fetch@noreply.github.com>
Received on Monday, 14 December 2015 15:10:16 UTC
I'd like an option to have a **deadline** for the server to respond, so that if the response doesn't arrive within a specified number of seconds, the fetch promise is rejected and *internally* (i.e. without any sort of abort/cancellation API exposed to JS) the request is aborted by the browser on the TCP/IP level, so that bandwidth is not wasted in case the response does come later.
```js
fetch('/slow', {deadline: 5000})
.then(called_if_response_is_quick, called_if_response_is_too_slow);
```
It'd be less wasteful equivalent of:
```js
const oldfetch = fetch;
fetch = function(input, opts) {
return new Promise((resolve, reject) => {
setTimeout(reject, opts.deadline);
oldfetch(input, opts).then(resolve, reject);
});
}
```
---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/179
Received on Monday, 14 December 2015 15:10:16 UTC