{"action":"created","comment":{"url":"https://api.github.com/repos/github/fetch/pulls/comments/169645647","pull_request_review_id":98203827,"id":169645647,"diff_hunk":"@@ -459,6 +488,17 @@\n         xhr.setRequestHeader(name, value)\n       })\n \n+      if (request.signal) {\n+        request.signal.addEventListener('abort', abortXhr)\n+\n+        xhr.onreadystatechange = function() {","path":"fetch.js","position":73,"original_position":73,"commit_id":"7f6b8d2eb3e7d64cc3e8ec2c93332939ab5d859c","original_commit_id":"7f6b8d2eb3e7d64cc3e8ec2c93332939ab5d859c","user":{"login":"joaovieira","id":474603,"avatar_url":"https://avatars0.githubusercontent.com/u/474603?v=4","gravatar_id":"","url":"https://api.github.com/users/joaovieira","html_url":"https://github.com/joaovieira","followers_url":"https://api.github.com/users/joaovieira/followers","following_url":"https://api.github.com/users/joaovieira/following{/other_user}","gists_url":"https://api.github.com/users/joaovieira/gists{/gist_id}","starred_url":"https://api.github.com/users/joaovieira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaovieira/subscriptions","organizations_url":"https://api.github.com/users/joaovieira/orgs","repos_url":"https://api.github.com/users/joaovieira/repos","events_url":"https://api.github.com/users/joaovieira/events{/privacy}","received_events_url":"https://api.github.com/users/joaovieira/received_events","type":"User","site_admin":false},"body":"this is the cleanest/safest way to know when the request has finished, regardless of the result, instead of having to do so on every callback:\r\n\r\n```js\r\nxhr.onload = function() {\r\n  ...\r\n  request.signal.removeEventListener('abort', abortXhr)\r\n}\r\n\r\nxhr.onabort = function() {\r\n  ...\r\n  request.signal.removeEventListener('abort', abortXhr)\r\n}\r\n\r\nxhr.onerror = function() {\r\n  ...\r\n  request.signal.removeEventListener('abort', abortXhr)\r\n}\r\n\r\nxhr.onprogress = function() {\r\n  ...\r\n  // should I remove listener? no.\r\n}\r\n\r\n// what other events there are? timeout?\r\n...\r\n```\r\n\r\nhaving the `removeListener` close to `addListener` is also easier to read/maintain.","created_at":"2018-02-21T14:05:38Z","updated_at":"2018-02-21T14:05:38Z","html_url":"https://github.com/github/fetch/pull/592#discussion_r169645647","pull_request_url":"https://api.github.com/repos/github/fetch/pulls/592","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/github/fetch/pulls/comments/169645647"},"html":{"href":"https://github.com/github/fetch/pull/592#discussion_r169645647"},"pull_request":{"href":"https://api.github.com/repos/github/fetch/pulls/592"}},"in_reply_to_id":169303423},"pull_request":{"url":"https://api.github.com/repos/github/fetch/pulls/592","id":156940950,"html_url":"https://github.com/github/fetch/pull/592","diff_url":"https://github.com/github/fetch/pull/592.diff","patch_url":"https://github.com/github/fetch/pull/592.patch","issue_url":"https://api.github.com/repos/github/fetch/issues/592","number":592,"state":"open","locked":false,"title":"Support abort API","user":{"login":"jamesplease","id":2322305,"avatar_url":"https://avatars3.githubusercontent.com/u/2322305?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesplease","html_url":"https://github.com/jamesplease","followers_url":"https://api.github.com/users/jamesplease/followers","following_url":"https://api.github.com/users/jamesplease/following{/other_user}","gists_url":"https://api.github.com/users/jamesplease/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesplease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesplease/subscriptions","organizations_url":"https://api.github.com/users/jamesplease/orgs","repos_url":"https://api.github.com/users/jamesplease/repos","events_url":"https://api.github.com/users/jamesplease/events{/privacy}","received_events_url":"https://api.github.com/users/jamesplease/received_events","type":"User","site_admin":false},"body":"This is a quick pass at an attempt to resolve #547 . The intention is that it would supersede #572\r\n\r\nTodo:\r\n\r\n- [ ] Tests\r\n- [ ] ~~Verify that the feature detection works~~\r\n- [x] Update documentation\r\n\r\nFeedback is welcome! Thanks for reviewing :v:","created_at":"2017-12-07T09:21:19Z","updated_at":"2018-02-21T14:05:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24bcf0b248c01afcc067a9aa46347261a7275604","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/github/fetch/pulls/592/commits","review_comments_url":"https://api.github.com/repos/github/fetch/pulls/592/comments","review_comment_url":"https://api.github.com/repos/github/fetch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/github/fetch/issues/592/comments","statuses_url":"https://api.github.com/repos/github/fetch/statuses/7f6b8d2eb3e7d64cc3e8ec2c93332939ab5d859c","head":{"label":"jamesplease:abort-polyfill","ref":"abort-polyfill","sha":"7f6b8d2eb3e7d64cc3e8ec2c93332939ab5d859c","user":{"login":"jamesplease","id":2322305,"avatar_url":"https://avatars3.githubusercontent.com/u/2322305?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesplease","html_url":"https://github.com/jamesplease","followers_url":"https://api.github.com/users/jamesplease/followers","following_url":"https://api.github.com/users/jamesplease/following{/other_user}","gists_url":"https://api.github.com/users/jamesplease/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesplease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesplease/subscriptions","organizations_url":"https://api.github.com/users/jamesplease/orgs","repos_url":"https://api.github.com/users/jamesplease/repos","events_url":"https://api.github.com/users/jamesplease/events{/privacy}","received_events_url":"https://api.github.com/users/jamesplease/received_events","type":"User","site_admin":false},"repo":{"id":50791257,"name":"fetch","full_name":"jamesplease/fetch","owner":{"login":"jamesplease","id":2322305,"avatar_url":"https://avatars3.githubusercontent.com/u/2322305?v=4","gravatar_id":"","url":"https://api.github.com/users/jamesplease","html_url":"https://github.com/jamesplease","followers_url":"https://api.github.com/users/jamesplease/followers","following_url":"https://api.github.com/users/jamesplease/following{/other_user}","gists_url":"https://api.github.com/users/jamesplease/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesplease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesplease/subscriptions","organizations_url":"https://api.github.com/users/jamesplease/orgs","repos_url":"https://api.github.com/users/jamesplease/repos","events_url":"https://api.github.com/users/jamesplease/events{/privacy}","received_events_url":"https://api.github.com/users/jamesplease/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamesplease/fetch","description":"A window.fetch JavaScript polyfill.","fork":true,"url":"https://api.github.com/repos/jamesplease/fetch","forks_url":"https://api.github.com/repos/jamesplease/fetch/forks","keys_url":"https://api.github.com/repos/jamesplease/fetch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamesplease/fetch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamesplease/fetch/teams","hooks_url":"https://api.github.com/repos/jamesplease/fetch/hooks","issue_events_url":"https://api.github.com/repos/jamesplease/fetch/issues/events{/number}","events_url":"https://api.github.com/repos/jamesplease/fetch/events","assignees_url":"https://api.github.com/repos/jamesplease/fetch/assignees{/user}","branches_url":"https://api.github.com/repos/jamesplease/fetch/branches{/branch}","tags_url":"https://api.github.com/repos/jamesplease/fetch/tags","blobs_url":"https://api.github.com/repos/jamesplease/fetch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamesplease/fetch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamesplease/fetch/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamesplease/fetch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamesplease/fetch/statuses/{sha}","languages_url":"https://api.github.com/repos/jamesplease/fetch/languages","stargazers_url":"https://api.github.com/repos/jamesplease/fetch/stargazers","contributors_url":"https://api.github.com/repos/jamesplease/fetch/contributors","subscribers_url":"https://api.github.com/repos/jamesplease/fetch/subscribers","subscription_url":"https://api.github.com/repos/jamesplease/fetch/subscription","commits_url":"https://api.github.com/repos/jamesplease/fetch/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamesplease/fetch/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamesplease/fetch/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamesplease/fetch/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamesplease/fetch/contents/{+path}","compare_url":"https://api.github.com/repos/jamesplease/fetch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamesplease/fetch/merges","archive_url":"https://api.github.com/repos/jamesplease/fetch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamesplease/fetch/downloads","issues_url":"https://api.github.com/repos/jamesplease/fetch/issues{/number}","pulls_url":"https://api.github.com/repos/jamesplease/fetch/pulls{/number}","milestones_url":"https://api.github.com/repos/jamesplease/fetch/milestones{/number}","notifications_url":"https://api.github.com/repos/jamesplease/fetch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamesplease/fetch/labels{/name}","releases_url":"https://api.github.com/repos/jamesplease/fetch/releases{/id}","deployments_url":"https://api.github.com/repos/jamesplease/fetch/deployments","created_at":"2016-01-31T19:33:23Z","updated_at":"2016-01-31T19:33:24Z","pushed_at":"2018-02-04T18:41:31Z","git_url":"git://github.com/jamesplease/fetch.git","ssh_url":"git@github.com:jamesplease/fetch.git","clone_url":"https://github.com/jamesplease/fetch.git","svn_url":"https://github.com/jamesplease/fetch","homepage":"http://github.github.io/fetch/","size":367,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"github:master","ref":"master","sha":"7a692dc519a3a110526a26c7e252f99991510c2a","user":{"login":"github","id":9919,"avatar_url":"https://avatars1.githubusercontent.com/u/9919?v=4","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"repo":{"id":25136308,"name":"fetch","full_name":"github/fetch","owner":{"login":"github","id":9919,"avatar_url":"https://avatars1.githubusercontent.com/u/9919?v=4","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/github/fetch","description":"A window.fetch JavaScript polyfill.","fork":false,"url":"https://api.github.com/repos/github/fetch","forks_url":"https://api.github.com/repos/github/fetch/forks","keys_url":"https://api.github.com/repos/github/fetch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/fetch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/fetch/teams","hooks_url":"https://api.github.com/repos/github/fetch/hooks","issue_events_url":"https://api.github.com/repos/github/fetch/issues/events{/number}","events_url":"https://api.github.com/repos/github/fetch/events","assignees_url":"https://api.github.com/repos/github/fetch/assignees{/user}","branches_url":"https://api.github.com/repos/github/fetch/branches{/branch}","tags_url":"https://api.github.com/repos/github/fetch/tags","blobs_url":"https://api.github.com/repos/github/fetch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/fetch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/fetch/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/fetch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/fetch/statuses/{sha}","languages_url":"https://api.github.com/repos/github/fetch/languages","stargazers_url":"https://api.github.com/repos/github/fetch/stargazers","contributors_url":"https://api.github.com/repos/github/fetch/contributors","subscribers_url":"https://api.github.com/repos/github/fetch/subscribers","subscription_url":"https://api.github.com/repos/github/fetch/subscription","commits_url":"https://api.github.com/repos/github/fetch/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/fetch/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/fetch/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/fetch/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/fetch/contents/{+path}","compare_url":"https://api.github.com/repos/github/fetch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/fetch/merges","archive_url":"https://api.github.com/repos/github/fetch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/fetch/downloads","issues_url":"https://api.github.com/repos/github/fetch/issues{/number}","pulls_url":"https://api.github.com/repos/github/fetch/pulls{/number}","milestones_url":"https://api.github.com/repos/github/fetch/milestones{/number}","notifications_url":"https://api.github.com/repos/github/fetch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/fetch/labels{/name}","releases_url":"https://api.github.com/repos/github/fetch/releases{/id}","deployments_url":"https://api.github.com/repos/github/fetch/deployments","created_at":"2014-10-13T00:26:19Z","updated_at":"2018-02-21T12:59:08Z","pushed_at":"2018-02-16T09:40:07Z","git_url":"git://github.com/github/fetch.git","ssh_url":"git@github.com:github/fetch.git","clone_url":"https://github.com/github/fetch.git","svn_url":"https://github.com/github/fetch","homepage":"http://github.github.io/fetch/","size":343,"stargazers_count":17817,"watchers_count":17817,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1460,"mirror_url":null,"archived":false,"open_issues_count":20,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1460,"open_issues":20,"watchers":17817,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/github/fetch/pulls/592"},"html":{"href":"https://github.com/github/fetch/pull/592"},"issue":{"href":"https://api.github.com/repos/github/fetch/issues/592"},"comments":{"href":"https://api.github.com/repos/github/fetch/issues/592/comments"},"review_comments":{"href":"https://api.github.com/repos/github/fetch/pulls/592/comments"},"review_comment":{"href":"https://api.github.com/repos/github/fetch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/github/fetch/pulls/592/commits"},"statuses":{"href":"https://api.github.com/repos/github/fetch/statuses/7f6b8d2eb3e7d64cc3e8ec2c93332939ab5d859c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"joaovieira"}}