New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution order with async functions/then isn' the same with the origin code #8938

MondoGao opened this Issue Oct 29, 2018 · 2 comments


None yet
3 participants

MondoGao commented Oct 29, 2018

Bug Report

Current Behavior

Compiled code's execution order with async functions isn' the same with the origin code. More detail below.



Input Code

async function async1() {
  const p = async2()
  p.then(() => console.log('async2 1st then'))
  await p
  console.log('async2 after await')

async function async2() {

new Promise(resolve => {
  console.log('2rd promise handler')
}).then(() => {
  console.log('2rd promise 1st then')

Expected behavior/code

The above code should behave exactly the same, as in Chrome 71+:


  • Babel version(s): 6.26.0
  • Node/npm version: Node 11
  • Chrome: 71

Additional context/Screenshots

The behavior was inconsistent in older versions of node and chrome, but now they seem to be aligned.


This comment has been minimized.


babel-bot commented Oct 29, 2018

Hey @MondoGao! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.


This comment has been minimized.


nicolo-ribaudo commented Oct 30, 2018

If anyone wants to fix this bug, it is probably a problem with the _asyncToGenerator helper. I suggest debugging this by only enabling @babel/plugin-transform-async-to-generator, since regenerator (used by the presets) adds a lot of noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment