{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/fetch/issues/20","labels_url":"https://api.github.com/repos/whatwg/fetch/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/fetch/issues/20/comments","events_url":"https://api.github.com/repos/whatwg/fetch/issues/20/events","html_url":"https://github.com/whatwg/fetch/issues/20","id":54466002,"number":20,"title":"Add timeout option","user":{"login":"wheresrhys","id":447559,"avatar_url":"https://avatars.githubusercontent.com/u/447559?v=3","gravatar_id":"","url":"https://api.github.com/users/wheresrhys","html_url":"https://github.com/wheresrhys","followers_url":"https://api.github.com/users/wheresrhys/followers","following_url":"https://api.github.com/users/wheresrhys/following{/other_user}","gists_url":"https://api.github.com/users/wheresrhys/gists{/gist_id}","starred_url":"https://api.github.com/users/wheresrhys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wheresrhys/subscriptions","organizations_url":"https://api.github.com/users/wheresrhys/orgs","repos_url":"https://api.github.com/users/wheresrhys/repos","events_url":"https://api.github.com/users/wheresrhys/events{/privacy}","received_events_url":"https://api.github.com/users/wheresrhys/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":35,"created_at":"2015-01-15T15:59:42Z","updated_at":"2015-12-11T15:56:58Z","closed_at":null,"body":"Most ajax libraries and xhr itself offer a convenient way to set a timeout for a request. Adding `timeout` to the properties accepted in the options object therefore seems like a sensible addition to fetch.\r\n\r\nhttps://github.com/github/fetch/pull/68"},"comment":{"url":"https://api.github.com/repos/whatwg/fetch/issues/comments/163973445","html_url":"https://github.com/whatwg/fetch/issues/20#issuecomment-163973445","issue_url":"https://api.github.com/repos/whatwg/fetch/issues/20","id":163973445,"user":{"login":"DiThi","id":1127198,"avatar_url":"https://avatars.githubusercontent.com/u/1127198?v=3","gravatar_id":"","url":"https://api.github.com/users/DiThi","html_url":"https://github.com/DiThi","followers_url":"https://api.github.com/users/DiThi/followers","following_url":"https://api.github.com/users/DiThi/following{/other_user}","gists_url":"https://api.github.com/users/DiThi/gists{/gist_id}","starred_url":"https://api.github.com/users/DiThi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DiThi/subscriptions","organizations_url":"https://api.github.com/users/DiThi/orgs","repos_url":"https://api.github.com/users/DiThi/repos","events_url":"https://api.github.com/users/DiThi/events{/privacy}","received_events_url":"https://api.github.com/users/DiThi/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T15:56:58Z","updated_at":"2015-12-11T15:56:58Z","body":"I subscribed to this issue time ago because I need connections to fail when they're stuck. However, it's common to have many requests pending because the browser only downloads a limited number simultaneously. Therefore we need a way to timeout a whole group of promises when there hasn't been activity for X amount of time.\r\n\r\nI've been using the `timeout` property of XHR but it turns out it's a timeout since `send()` was called, which is like setting a `setTimeout` regardless of traffic. I had to remove the `timeout` because it always failed on slow connections.\r\n\r\nIn other words, we need several things, independently:\r\n* XHR style timeout, a.k.a. **deadline**: reject the promise when it took too long. Seems easy to polyfill.\r\n* Abort: not needed for this specific issue but very useful (e.g. to cut in traffic and leave room for an alternative, smaller request). #27\r\n* **Timeout since last received data. IMHO, the spec should specify the client will handle stuck files and re-start the connection.**"}}