{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1170","repository_url":"https://api.github.com/repos/petkaantonov/bluebird","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1170/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1170/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1170/events","html_url":"https://github.com/petkaantonov/bluebird/issues/1170","id":167654142,"number":1170,"title":"Bluebird.coroutine() is sometimes synchronous","user":{"login":"STRML","id":1197375,"avatar_url":"https://avatars.githubusercontent.com/u/1197375?v=3","gravatar_id":"","url":"https://api.github.com/users/STRML","html_url":"https://github.com/STRML","followers_url":"https://api.github.com/users/STRML/followers","following_url":"https://api.github.com/users/STRML/following{/other_user}","gists_url":"https://api.github.com/users/STRML/gists{/gist_id}","starred_url":"https://api.github.com/users/STRML/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STRML/subscriptions","organizations_url":"https://api.github.com/users/STRML/orgs","repos_url":"https://api.github.com/users/STRML/repos","events_url":"https://api.github.com/users/STRML/events{/privacy}","received_events_url":"https://api.github.com/users/STRML/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/petkaantonov/bluebird/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-26T16:36:53Z","updated_at":"2016-08-04T13:12:04Z","closed_at":"2016-08-03T23:22:17Z","body":"This is with latest Bluebird (3.4.1) and Babel (6.11.4).\r\n\r\nMany Babel users are using `Bluebird.coroutine()` in combination with `transform-async-to-module-method` to have Bluebird shim `async/await`.\r\n\r\nUnfortunately, it's not a perfect shim. The following code:\r\n\r\n```js\r\nasync function foo() {\r\n  await syncFn();\r\n  console.log(3);\r\n}\r\nasync function syncFn() {\r\n  return;\r\n}\r\nconsole.log(1);\r\nfoo();\r\nconsole.log(2);\r\n```\r\n\r\nprints `1 3 2` with `Bluebird.coroutine()` and `1 2 3` with the default `transform-async-to-generator` method.\r\n\r\nI've created this [Phabricator ticket](https://phabricator.babeljs.io/T7511) to track but it appears the issue lies here.\r\n\r\nThe above code transpiles to this, which I have cleaned up for readability:\r\n\r\n```js\r\nvar Bluebird = require('bluebird');\r\n\r\nfunction foo() {\r\n  return Bluebird.coroutine(function* () {\r\n    yield syncFn();\r\n    console.log(3);\r\n  })();\r\n}\r\n\r\nfunction syncFn() {\r\n  return Bluebird.coroutine(function* () {\r\n    return;\r\n  })();\r\n}\r\n\r\nconsole.log(1);\r\nfoo();\r\nconsole.log(2);\r\n```\r\n\r\nThis is easily runnable in any Node runtime that supports generators:\r\n\r\n```\r\n$ node syncCoroutines.js\r\n1\r\n3\r\n2\r\n```\r\n\r\nIs this intended behavior?"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/237548235","html_url":"https://github.com/petkaantonov/bluebird/issues/1170#issuecomment-237548235","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/1170","id":237548235,"user":{"login":"overlookmotel","id":557937,"avatar_url":"https://avatars.githubusercontent.com/u/557937?v=3","gravatar_id":"","url":"https://api.github.com/users/overlookmotel","html_url":"https://github.com/overlookmotel","followers_url":"https://api.github.com/users/overlookmotel/followers","following_url":"https://api.github.com/users/overlookmotel/following{/other_user}","gists_url":"https://api.github.com/users/overlookmotel/gists{/gist_id}","starred_url":"https://api.github.com/users/overlookmotel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overlookmotel/subscriptions","organizations_url":"https://api.github.com/users/overlookmotel/orgs","repos_url":"https://api.github.com/users/overlookmotel/repos","events_url":"https://api.github.com/users/overlookmotel/events{/privacy}","received_events_url":"https://api.github.com/users/overlookmotel/received_events","type":"User","site_admin":false},"created_at":"2016-08-04T13:12:04Z","updated_at":"2016-08-04T13:12:04Z","body":"Amazing you guys fixed this so fast. Any idea when it's likely to get pushed to npm?"}}
{"actor":{"display_login":"overlookmotel"}}