{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/91788097","pull_request_review_id":12300625,"id":91788097,"diff_hunk":"@@ -187,17 +206,56 @@ class GatherRunner {\n       const status = `Retrieving: ${gatherer.name}`;\n       return chain.then(_ => {\n         log.log('status', status);\n-        return gatherer.afterPass(options, passData);\n-      }).then(ret => {\n+        const artifactPromise = Promise.resolve().then(_ => gatherer.afterPass(options, passData));\n+        gathererResults[gatherer.name].push(artifactPromise);\n+        return artifactPromise.catch(err => {\n+          if (!err.recoverable) {\n+            throw err;\n+          }\n+        });\n+      }).then(_ => {\n         log.verbose('statusEnd', status);\n-        return ret;\n       });\n     }, pass);\n \n     // Resolve on tracing data using passName from config.\n     return pass.then(_ => passData);\n   }\n \n+  /**\n+   * Takes the results of each gatherer phase for each gatherer and uses the\n+   * last produced value (that's not undefined) as the artifact for that\n+   * gatherer. If a recoverable error was rejected from a gatherer phase,\n+   * uses that error as the artifact instead.\n+   * @param {!Object<!Array<!Promise<*>>} gathererResults\n+   * @return {!Promise<!Artifacts>}\n+   */\n+  static collectArtifacts(gathererResults) {\n+    const artifacts = {};\n+\n+    return Object.keys(gathererResults).reduce((chain, gathererName) => {\n+      return chain.then(_ => {\n+        const phaseResultsPromises = gathererResults[gathererName];\n+        return Promise.all(phaseResultsPromises).then(phaseResults => {\n+          // Take last defined pass result as artifact.\n+          const artifact = phaseResults.reduceRight((prev, curr) => {","path":"lighthouse-core/gather/gather-runner.js","position":113,"original_position":113,"commit_id":"c2d2436d7be279d6f15a13a6067ac426911c51ad","original_commit_id":"c2d2436d7be279d6f15a13a6067ac426911c51ad","user":{"login":"patrickhulce","id":2301202,"avatar_url":"https://avatars.githubusercontent.com/u/2301202?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickhulce","html_url":"https://github.com/patrickhulce","followers_url":"https://api.github.com/users/patrickhulce/followers","following_url":"https://api.github.com/users/patrickhulce/following{/other_user}","gists_url":"https://api.github.com/users/patrickhulce/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickhulce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickhulce/subscriptions","organizations_url":"https://api.github.com/users/patrickhulce/orgs","repos_url":"https://api.github.com/users/patrickhulce/repos","events_url":"https://api.github.com/users/patrickhulce/events{/privacy}","received_events_url":"https://api.github.com/users/patrickhulce/received_events","type":"User","site_admin":false},"body":"`reduceRight` makes this a bit confusing to understand for how simple a job it's doing. what about just a filter and taking the last one?","created_at":"2016-12-09T20:19:12Z","updated_at":"2016-12-09T20:19:12Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/1122#discussion_r91788097","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/91788097"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/1122#discussion_r91788097"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122","id":97052197,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/1122","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/1122.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/1122.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1122","number":1122,"state":"open","locked":false,"title":"refactor: get artifacts directly from running gatherer methods","user":{"login":"brendankenny","id":316891,"avatar_url":"https://avatars.githubusercontent.com/u/316891?v=3","gravatar_id":"","url":"https://api.github.com/users/brendankenny","html_url":"https://github.com/brendankenny","followers_url":"https://api.github.com/users/brendankenny/followers","following_url":"https://api.github.com/users/brendankenny/following{/other_user}","gists_url":"https://api.github.com/users/brendankenny/gists{/gist_id}","starred_url":"https://api.github.com/users/brendankenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendankenny/subscriptions","organizations_url":"https://api.github.com/users/brendankenny/orgs","repos_url":"https://api.github.com/users/brendankenny/repos","events_url":"https://api.github.com/users/brendankenny/events{/privacy}","received_events_url":"https://api.github.com/users/brendankenny/received_events","type":"User","site_admin":false},"body":"R: @paulirish @patrickhulce \r\n\r\nnext part of #941\r\n\r\n- Removes `this.artifact` from gatherers and instead have gatherers return the artifact directly in whatever value is returned last from `beforePass()`, `pass()`, or `afterPass()`.\r\n- When gatherers reject on an error, we have a new opt-in property `recoverable` on the error that gather-runner checks. If set to `true`, it will turn that into an \"error artifact\", equivalent to the many versions of -1 artifacts we have today.\r\n- If `recoverable` isn't present, it throws the error and lighthouse exits on the error. By making it explicit when a gatherer expects an error, this should help catch more errors than our current system (which absorbs all errors in the gatherer stage)\r\n- gatherer's methods can return (or throw) synchronously or asynchronously\r\n\r\nThis PR doesn't actually take advantage of recoverable errors yet, as it was already getting really big. Merely implements support for them, adds unit tests for them, and gets rid of `gatherer.artifact` on all the current artifacts. So most work here is in `gather-runner.js` and `gather-runner-test.js`.\r\n\r\nFeel free to bikeshed/propose other control flows.\r\n\r\nNext PR will delete all the -1 nonsense from gatherers and replace with this system when we're certain this is the direction we want to go.","created_at":"2016-12-08T03:18:10Z","updated_at":"2016-12-09T20:30:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5788b59fb0079ff742d628c2398ac2fd58d922a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1122/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/c2d2436d7be279d6f15a13a6067ac426911c51ad","head":{"label":"GoogleChrome:artifactcleanup","ref":"artifactcleanup","sha":"c2d2436d7be279d6f15a13a6067ac426911c51ad","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":"Auditing, performance metrics, and best practices for Progressive Web Apps","fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2016-12-09T19:45:15Z","pushed_at":"2016-12-09T18:41:03Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":"","size":11166,"stargazers_count":4913,"watchers_count":4913,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":183,"mirror_url":null,"open_issues_count":149,"forks":183,"open_issues":149,"watchers":4913,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"aca56434e05b7ca85f8ef3f805577f855c00d011","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":"Auditing, performance metrics, and best practices for Progressive Web Apps","fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2016-12-09T19:45:15Z","pushed_at":"2016-12-09T18:41:03Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":"","size":11166,"stargazers_count":4913,"watchers_count":4913,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":183,"mirror_url":null,"open_issues_count":149,"forks":183,"open_issues":149,"watchers":4913,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/1122"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1122"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/1122/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/1122/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/c2d2436d7be279d6f15a13a6067ac426911c51ad"}}}}
{"actor":{"display_login":"patrickhulce"}}