{"action":"created","comment":{"url":"https://api.github.com/repos/iojs/io.js/pulls/comments/26425961","id":26425961,"diff_hunk":"@@ -263,6 +265,9 @@ class Environment {\n     enum Fields {\n       // Set this to not zero if the init hook should be called.\n       kCallInitHook,\n+      // Set this to not zero if async wrap should be enabled. This is\n+      // automatically set when SetupHooks is called.\n+      kEnabled,","path":"src/env.h","position":15,"original_position":15,"commit_id":"d44132c7926d6927b3f4b28936351a39be2ca5ab","original_commit_id":"d44132c7926d6927b3f4b28936351a39be2ca5ab","user":{"login":"AndreasMadsen","id":505333,"avatar_url":"https://avatars.githubusercontent.com/u/505333?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasMadsen","html_url":"https://github.com/AndreasMadsen","followers_url":"https://api.github.com/users/AndreasMadsen/followers","following_url":"https://api.github.com/users/AndreasMadsen/following{/other_user}","gists_url":"https://api.github.com/users/AndreasMadsen/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasMadsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasMadsen/subscriptions","organizations_url":"https://api.github.com/users/AndreasMadsen/orgs","repos_url":"https://api.github.com/users/AndreasMadsen/repos","events_url":"https://api.github.com/users/AndreasMadsen/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasMadsen/received_events","type":"User","site_admin":false},"body":">  I know you know this, but to reiterate. The point was that before/after don't run unless init runs, so enabling init implies enabling the others.\r\n\r\nThanks for reiterating, I actually didn't realize that. The comment in (https://github.com/iojs/io.js/blob/v1.x/src/async-wrap.cc#L39) is rather confusing then:\r\n> This only affects the init callback.\r\n\r\nI realize now that it also says: \r\n> If the init callback was called, then the pre/post callbacks will automatically be called.\r\n\r\nwhich should be read as \"if and only if\". Sometimes I think my math education have kills all implicit human understanding :)\r\n\r\nIn any case I find it a bit confusing, the `kCallInitHook` should really just be called `kEnable` then. Or is it because `before` and `after` callbacks can still be called after `kEnable` is called?\r\n\r\nI would propose having a `kEnable` which enables (`1`) or short circuit (`0`) the `async_wrap` stuff. Such that some or no callbacks are called.\r\n\r\nI'm not sure how much of a performance hit a no-opt call is these days, but I guess having  `kCallInitHook`, `kCallBeforeHook` and `kCallAfterHook` flags would make sense. The flags are such that the respective callback is only called the flag is set. For instance I don't think there is any reason for me to have an `after` hook in [`trace (L80)`](https://github.com/AndreasMadsen/trace/blob/master/trace.js#L80)\r\n\r\nThe logic behind preventing the `before` and `after` hook calls if `init` wasn't called, is then removed. I don't think this is particularly useful, it seams like it is user protection and it is easy to implement in userland.","created_at":"2015-03-13T21:50:49Z","updated_at":"2015-03-13T21:50:49Z","html_url":"https://github.com/iojs/io.js/pull/665#discussion_r26425961","pull_request_url":"https://api.github.com/repos/iojs/io.js/pulls/665","_links":{"self":{"href":"https://api.github.com/repos/iojs/io.js/pulls/comments/26425961"},"html":{"href":"https://github.com/iojs/io.js/pull/665#discussion_r26425961"},"pull_request":{"href":"https://api.github.com/repos/iojs/io.js/pulls/665"}}},"pull_request":{"url":"https://api.github.com/repos/iojs/io.js/pulls/665","id":28362347,"html_url":"https://github.com/iojs/io.js/pull/665","diff_url":"https://github.com/iojs/io.js/pull/665.diff","patch_url":"https://github.com/iojs/io.js/pull/665.patch","issue_url":"https://api.github.com/repos/iojs/io.js/issues/665","number":665,"state":"open","locked":false,"title":"async-wrap: always call before and after hooks","user":{"login":"AndreasMadsen","id":505333,"avatar_url":"https://avatars.githubusercontent.com/u/505333?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasMadsen","html_url":"https://github.com/AndreasMadsen","followers_url":"https://api.github.com/users/AndreasMadsen/followers","following_url":"https://api.github.com/users/AndreasMadsen/following{/other_user}","gists_url":"https://api.github.com/users/AndreasMadsen/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasMadsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasMadsen/subscriptions","organizations_url":"https://api.github.com/users/AndreasMadsen/orgs","repos_url":"https://api.github.com/users/AndreasMadsen/repos","events_url":"https://api.github.com/users/AndreasMadsen/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasMadsen/received_events","type":"User","site_admin":false},"body":"This patch allows the before and after hook to be called even if the\r\nkCallInitHook flag is 0.\r\n\r\n* `test/parallel/test-async-wrap-no-init-hook.js` did not pass before.\r\n* `test/parallel/test-async-wrap-init-hook.js` did pass before. I just added it for the sake of completeness.\r\n\r\n_issue tracking: https://github.com/AndreasMadsen/trace/issues/12_","created_at":"2015-01-30T13:53:27Z","updated_at":"2015-03-13T21:50:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edd822026f244dfa5fb9f1e091dbcfb5f3e12fce","assignee":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/iojs/io.js/pulls/665/commits","review_comments_url":"https://api.github.com/repos/iojs/io.js/pulls/665/comments","review_comment_url":"https://api.github.com/repos/iojs/io.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iojs/io.js/issues/665/comments","statuses_url":"https://api.github.com/repos/iojs/io.js/statuses/d44132c7926d6927b3f4b28936351a39be2ca5ab","head":{"label":"AndreasMadsen:async-hook-init-fix","ref":"async-hook-init-fix","sha":"d44132c7926d6927b3f4b28936351a39be2ca5ab","user":{"login":"AndreasMadsen","id":505333,"avatar_url":"https://avatars.githubusercontent.com/u/505333?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasMadsen","html_url":"https://github.com/AndreasMadsen","followers_url":"https://api.github.com/users/AndreasMadsen/followers","following_url":"https://api.github.com/users/AndreasMadsen/following{/other_user}","gists_url":"https://api.github.com/users/AndreasMadsen/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasMadsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasMadsen/subscriptions","organizations_url":"https://api.github.com/users/AndreasMadsen/orgs","repos_url":"https://api.github.com/users/AndreasMadsen/repos","events_url":"https://api.github.com/users/AndreasMadsen/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasMadsen/received_events","type":"User","site_admin":false},"repo":{"id":30072119,"name":"io.js","full_name":"AndreasMadsen/io.js","owner":{"login":"AndreasMadsen","id":505333,"avatar_url":"https://avatars.githubusercontent.com/u/505333?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreasMadsen","html_url":"https://github.com/AndreasMadsen","followers_url":"https://api.github.com/users/AndreasMadsen/followers","following_url":"https://api.github.com/users/AndreasMadsen/following{/other_user}","gists_url":"https://api.github.com/users/AndreasMadsen/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreasMadsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreasMadsen/subscriptions","organizations_url":"https://api.github.com/users/AndreasMadsen/orgs","repos_url":"https://api.github.com/users/AndreasMadsen/repos","events_url":"https://api.github.com/users/AndreasMadsen/events{/privacy}","received_events_url":"https://api.github.com/users/AndreasMadsen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AndreasMadsen/io.js","description":"A friendly fork of Node.js with an open governance model","fork":true,"url":"https://api.github.com/repos/AndreasMadsen/io.js","forks_url":"https://api.github.com/repos/AndreasMadsen/io.js/forks","keys_url":"https://api.github.com/repos/AndreasMadsen/io.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AndreasMadsen/io.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AndreasMadsen/io.js/teams","hooks_url":"https://api.github.com/repos/AndreasMadsen/io.js/hooks","issue_events_url":"https://api.github.com/repos/AndreasMadsen/io.js/issues/events{/number}","events_url":"https://api.github.com/repos/AndreasMadsen/io.js/events","assignees_url":"https://api.github.com/repos/AndreasMadsen/io.js/assignees{/user}","branches_url":"https://api.github.com/repos/AndreasMadsen/io.js/branches{/branch}","tags_url":"https://api.github.com/repos/AndreasMadsen/io.js/tags","blobs_url":"https://api.github.com/repos/AndreasMadsen/io.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AndreasMadsen/io.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AndreasMadsen/io.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/AndreasMadsen/io.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AndreasMadsen/io.js/statuses/{sha}","languages_url":"https://api.github.com/repos/AndreasMadsen/io.js/languages","stargazers_url":"https://api.github.com/repos/AndreasMadsen/io.js/stargazers","contributors_url":"https://api.github.com/repos/AndreasMadsen/io.js/contributors","subscribers_url":"https://api.github.com/repos/AndreasMadsen/io.js/subscribers","subscription_url":"https://api.github.com/repos/AndreasMadsen/io.js/subscription","commits_url":"https://api.github.com/repos/AndreasMadsen/io.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/AndreasMadsen/io.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/AndreasMadsen/io.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/AndreasMadsen/io.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/AndreasMadsen/io.js/contents/{+path}","compare_url":"https://api.github.com/repos/AndreasMadsen/io.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AndreasMadsen/io.js/merges","archive_url":"https://api.github.com/repos/AndreasMadsen/io.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AndreasMadsen/io.js/downloads","issues_url":"https://api.github.com/repos/AndreasMadsen/io.js/issues{/number}","pulls_url":"https://api.github.com/repos/AndreasMadsen/io.js/pulls{/number}","milestones_url":"https://api.github.com/repos/AndreasMadsen/io.js/milestones{/number}","notifications_url":"https://api.github.com/repos/AndreasMadsen/io.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AndreasMadsen/io.js/labels{/name}","releases_url":"https://api.github.com/repos/AndreasMadsen/io.js/releases{/id}","created_at":"2015-01-30T13:00:11Z","updated_at":"2015-01-30T13:00:15Z","pushed_at":"2015-01-30T20:59:44Z","git_url":"git://github.com/AndreasMadsen/io.js.git","ssh_url":"git@github.com:AndreasMadsen/io.js.git","clone_url":"https://github.com/AndreasMadsen/io.js.git","svn_url":"https://github.com/AndreasMadsen/io.js","homepage":"https://iojs.org","size":118907,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"v1.x"}},"base":{"label":"iojs:v1.x","ref":"v1.x","sha":"53e200acc2b58fc3b33505b61a2f60d542e85f20","user":{"login":"iojs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/iojs","html_url":"https://github.com/iojs","followers_url":"https://api.github.com/users/iojs/followers","following_url":"https://api.github.com/users/iojs/following{/other_user}","gists_url":"https://api.github.com/users/iojs/gists{/gist_id}","starred_url":"https://api.github.com/users/iojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iojs/subscriptions","organizations_url":"https://api.github.com/users/iojs/orgs","repos_url":"https://api.github.com/users/iojs/repos","events_url":"https://api.github.com/users/iojs/events{/privacy}","received_events_url":"https://api.github.com/users/iojs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"io.js","full_name":"iojs/io.js","owner":{"login":"iojs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/iojs","html_url":"https://github.com/iojs","followers_url":"https://api.github.com/users/iojs/followers","following_url":"https://api.github.com/users/iojs/following{/other_user}","gists_url":"https://api.github.com/users/iojs/gists{/gist_id}","starred_url":"https://api.github.com/users/iojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iojs/subscriptions","organizations_url":"https://api.github.com/users/iojs/orgs","repos_url":"https://api.github.com/users/iojs/repos","events_url":"https://api.github.com/users/iojs/events{/privacy}","received_events_url":"https://api.github.com/users/iojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iojs/io.js","description":"A friendly fork of Node.js with an open governance model","fork":false,"url":"https://api.github.com/repos/iojs/io.js","forks_url":"https://api.github.com/repos/iojs/io.js/forks","keys_url":"https://api.github.com/repos/iojs/io.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iojs/io.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iojs/io.js/teams","hooks_url":"https://api.github.com/repos/iojs/io.js/hooks","issue_events_url":"https://api.github.com/repos/iojs/io.js/issues/events{/number}","events_url":"https://api.github.com/repos/iojs/io.js/events","assignees_url":"https://api.github.com/repos/iojs/io.js/assignees{/user}","branches_url":"https://api.github.com/repos/iojs/io.js/branches{/branch}","tags_url":"https://api.github.com/repos/iojs/io.js/tags","blobs_url":"https://api.github.com/repos/iojs/io.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iojs/io.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iojs/io.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/iojs/io.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iojs/io.js/statuses/{sha}","languages_url":"https://api.github.com/repos/iojs/io.js/languages","stargazers_url":"https://api.github.com/repos/iojs/io.js/stargazers","contributors_url":"https://api.github.com/repos/iojs/io.js/contributors","subscribers_url":"https://api.github.com/repos/iojs/io.js/subscribers","subscription_url":"https://api.github.com/repos/iojs/io.js/subscription","commits_url":"https://api.github.com/repos/iojs/io.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/iojs/io.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/iojs/io.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/iojs/io.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/iojs/io.js/contents/{+path}","compare_url":"https://api.github.com/repos/iojs/io.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iojs/io.js/merges","archive_url":"https://api.github.com/repos/iojs/io.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iojs/io.js/downloads","issues_url":"https://api.github.com/repos/iojs/io.js/issues{/number}","pulls_url":"https://api.github.com/repos/iojs/io.js/pulls{/number}","milestones_url":"https://api.github.com/repos/iojs/io.js/milestones{/number}","notifications_url":"https://api.github.com/repos/iojs/io.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iojs/io.js/labels{/name}","releases_url":"https://api.github.com/repos/iojs/io.js/releases{/id}","created_at":"2014-11-26T19:57:11Z","updated_at":"2015-03-13T20:55:03Z","pushed_at":"2015-03-13T20:55:02Z","git_url":"git://github.com/iojs/io.js.git","ssh_url":"git@github.com:iojs/io.js.git","clone_url":"https://github.com/iojs/io.js.git","svn_url":"https://github.com/iojs/io.js","homepage":"https://iojs.org","size":154458,"stargazers_count":11040,"watchers_count":11040,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":714,"mirror_url":null,"open_issues_count":192,"forks":714,"open_issues":192,"watchers":11040,"default_branch":"v1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/iojs/io.js/pulls/665"},"html":{"href":"https://github.com/iojs/io.js/pull/665"},"issue":{"href":"https://api.github.com/repos/iojs/io.js/issues/665"},"comments":{"href":"https://api.github.com/repos/iojs/io.js/issues/665/comments"},"review_comments":{"href":"https://api.github.com/repos/iojs/io.js/pulls/665/comments"},"review_comment":{"href":"https://api.github.com/repos/iojs/io.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iojs/io.js/pulls/665/commits"},"statuses":{"href":"https://api.github.com/repos/iojs/io.js/statuses/d44132c7926d6927b3f4b28936351a39be2ca5ab"}}}}