{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/5657","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/5657/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/5657/comments","events_url":"https://api.github.com/repos/babel/babel/issues/5657/events","html_url":"https://github.com/babel/babel/issues/5657","id":223541131,"number":5657,"title":"Babel async bug. ","user":{"login":"xialvjun","id":4413712,"avatar_url":"https://avatars3.githubusercontent.com/u/4413712?v=3","gravatar_id":"","url":"https://api.github.com/users/xialvjun","html_url":"https://github.com/xialvjun","followers_url":"https://api.github.com/users/xialvjun/followers","following_url":"https://api.github.com/users/xialvjun/following{/other_user}","gists_url":"https://api.github.com/users/xialvjun/gists{/gist_id}","starred_url":"https://api.github.com/users/xialvjun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xialvjun/subscriptions","organizations_url":"https://api.github.com/users/xialvjun/orgs","repos_url":"https://api.github.com/users/xialvjun/repos","events_url":"https://api.github.com/users/xialvjun/events{/privacy}","received_events_url":"https://api.github.com/users/xialvjun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-22T05:18:52Z","updated_at":"2017-04-22T06:38:32Z","closed_at":null,"body":"\r\n## Bug\r\n\r\n### Input Code\r\n\r\n[REPL LINK](http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&debug=false&code=function%20delay(time)%20%7B%0A%20%20return%20new%20Promise((resolve%2C%20reject)%3D%3E%7B%0A%20%20%20%20setTimeout(()%3D%3Eresolve()%2C%20time)%3B%0A%20%20%7D)%3B%0A%7D%0A%0A%5B1000%2C2000%2C3000%2C4000%5D.forEach(async%20(time)%20%3D%3E%20%7B%0A%20%20await%20delay(time)%3B%0A%20%20console.log(time)%3B%0A%7D)%0A%0Aconsole.log(%5B100000%5D)%0A)\r\n\r\n```js\r\nfunction delay(time) {\r\n  return new Promise((resolve, reject)=>{\r\n    setTimeout(()=>resolve(), time);\r\n  });\r\n}\r\n\r\n[1000,2000,3000,4000].forEach(async (time) => {\r\n  await delay(time);\r\n  console.log(time);\r\n})\r\n\r\nconsole.log([100000])\r\n```\r\n\r\n### Expected Behavior\r\nOutput: \r\n```js\r\nArray [100000]    // at 0s\r\n1000  // at 1s\r\n2000  // at 2s\r\n3000  // at 3s\r\n4000  // at 4s\r\n```\r\n\r\n> And the Chrome newest version just act like this.\r\n\r\n### Current Behavior\r\n<!--- If describing a bug, tell us what happens instead of the expected behavior -->\r\n<!--- If suggesting a change/improvement, explain the difference from current behavior -->\r\nOutput:\r\n```js\r\n// at 0s\r\nArray [100000]\r\n\r\n// at 1s\r\nArray [100000]\r\n1000\r\n\r\n// at 2s\r\nArray [100000]\r\n1000\r\n2000\r\n\r\n// at 3s\r\nArray [100000]\r\n1000\r\n2000\r\n3000\r\n\r\n// at 4s\r\nArray [100000]\r\n1000\r\n2000\r\n3000\r\n4000\r\n```\r\n\r\n> I thought the problem is at the function `_asyncToGenerator`."},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/296352357","html_url":"https://github.com/babel/babel/issues/5657#issuecomment-296352357","issue_url":"https://api.github.com/repos/babel/babel/issues/5657","id":296352357,"user":{"login":"xialvjun","id":4413712,"avatar_url":"https://avatars3.githubusercontent.com/u/4413712?v=3","gravatar_id":"","url":"https://api.github.com/users/xialvjun","html_url":"https://github.com/xialvjun","followers_url":"https://api.github.com/users/xialvjun/followers","following_url":"https://api.github.com/users/xialvjun/following{/other_user}","gists_url":"https://api.github.com/users/xialvjun/gists{/gist_id}","starred_url":"https://api.github.com/users/xialvjun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xialvjun/subscriptions","organizations_url":"https://api.github.com/users/xialvjun/orgs","repos_url":"https://api.github.com/users/xialvjun/repos","events_url":"https://api.github.com/users/xialvjun/events{/privacy}","received_events_url":"https://api.github.com/users/xialvjun/received_events","type":"User","site_admin":false},"created_at":"2017-04-22T06:38:32Z","updated_at":"2017-04-22T06:38:32Z","body":"Well, I have run this code on nodejs v7, and it act right. So the problem should be in the `regenerator-runtime` polyfill.\r\n\r\n```js\r\n\"use strict\";\r\n\r\nfunction _asyncToGenerator(fn) {\r\n  // just a copy of the babel generated function\r\n  ...\r\n}\r\n\r\nfunction delay(time) {\r\n  return new Promise((resolve, reject)=>{\r\n    setTimeout(()=>resolve(), time);\r\n  });\r\n}\r\n\r\n[1000,2000,3000,4000].forEach(_asyncToGenerator(function*(time) {\r\n  yield delay(time);\r\n  console.log(time);\r\n}))\r\n\r\nconsole.log([100000])\r\n```"}}
{"actor":{"display_login":"xialvjun"}}