{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/fetch/issues/396","repository_url":"https://api.github.com/repos/whatwg/fetch","labels_url":"https://api.github.com/repos/whatwg/fetch/issues/396/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/fetch/issues/396/comments","events_url":"https://api.github.com/repos/whatwg/fetch/issues/396/events","html_url":"https://github.com/whatwg/fetch/issues/396","id":182049750,"number":396,"title":"bodyUsed don't gets set properly ","user":{"login":"jimmywarting","id":1148376,"avatar_url":"https://avatars.githubusercontent.com/u/1148376?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmywarting","html_url":"https://github.com/jimmywarting","followers_url":"https://api.github.com/users/jimmywarting/followers","following_url":"https://api.github.com/users/jimmywarting/following{/other_user}","gists_url":"https://api.github.com/users/jimmywarting/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmywarting/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmywarting/subscriptions","organizations_url":"https://api.github.com/users/jimmywarting/orgs","repos_url":"https://api.github.com/users/jimmywarting/repos","events_url":"https://api.github.com/users/jimmywarting/events{/privacy}","received_events_url":"https://api.github.com/users/jimmywarting/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-10T15:50:09Z","updated_at":"2016-10-10T17:21:47Z","closed_at":null,"body":"When working with github/fetch polyfill and building a test i found a tiny issue:\r\n\r\n```javascript\r\nrs = new ReadableStream({})\r\nres = new Response(rs)\r\nres.body.getReader()\r\nconsole.log(res.bodyUsed) // false\r\n\r\ntry {\r\n  res.clone() // throws Failed to execute 'clone' on 'Response': Response body is already used(…)\r\n} catch (err) {\r\n  console.log(res.bodyUsed) // still false\r\n}\r\n\r\n```\r\n\r\nThink the bodyUsed flag should be set to true when you call getReader() ?\r\n\r\nIt's not until you call read() as the flag `bodyUsed` gets set to false\r\n```javascript\r\nrs = new ReadableStream({})\r\nres = new Response(rs)\r\nreader = res.body.getReader()\r\nreader.read()\r\nconsole.log(res.bodyUsed) // true\r\n// body used (don't call clone())\r\n```\r\n\r\nEnded up doing something like this:\r\n```javascript\r\n// this == instance of Response\r\nObject.defineProperty(this, 'bodyUsed', {\r\n  enumerable: true,\r\n  get: () => stream.locked\r\n})\r\n```"},"comment":{"url":"https://api.github.com/repos/whatwg/fetch/issues/comments/252684287","html_url":"https://github.com/whatwg/fetch/issues/396#issuecomment-252684287","issue_url":"https://api.github.com/repos/whatwg/fetch/issues/396","id":252684287,"user":{"login":"jimmywarting","id":1148376,"avatar_url":"https://avatars.githubusercontent.com/u/1148376?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmywarting","html_url":"https://github.com/jimmywarting","followers_url":"https://api.github.com/users/jimmywarting/followers","following_url":"https://api.github.com/users/jimmywarting/following{/other_user}","gists_url":"https://api.github.com/users/jimmywarting/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmywarting/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmywarting/subscriptions","organizations_url":"https://api.github.com/users/jimmywarting/orgs","repos_url":"https://api.github.com/users/jimmywarting/repos","events_url":"https://api.github.com/users/jimmywarting/events{/privacy}","received_events_url":"https://api.github.com/users/jimmywarting/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T17:21:47Z","updated_at":"2016-10-10T17:21:47Z","body":"Ok, can throw a ticket to chromium issue. It's true that bodyUsed should be set to true when you call getReader?"}}
{"actor":{"display_login":"jimmywarting"}}