Consider the following snippet where we are breaking out of loop from inside a try block:
async function foo() {
while (true) {
try {
await null; // important
console.log(1);
break;
}
catch {}
console.log(2);
}
}
foo();
The second console.log should never run because we exit the while loop prior to that. But using babel-plugin-transform-async-to-promises and running the output of babel, it executes both console.log statements and then exits the loop:
Consider the following snippet where we are breaking out of loop from inside a
try
block:The second
console.log
should never run because we exit thewhile
loop prior to that. But usingbabel-plugin-transform-async-to-promises
and running the output of babel, it executes bothconsole.log
statements and then exits the loop:Contrast that to: