lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2.03k stars 44 forks source link

Bug in handling async..await #37

Closed getify closed 5 years ago

getify commented 5 years ago

I'm not sure what's going on here... dunno if this is a babel transpilation issue or something about how your code instruments and captures each line of output.

This code is fine:

screen shot 2019-01-14 at 7 27 20 am

But when I add a single console.log(..) statement:

screen shot 2019-01-14 at 7 26 47 am

Notice the extra 3 (on line 3 of the output) before it then prints 2 and 3 (in the correct order).

Here's an even more severe illustration of whatever the bug is:

screen shot 2019-01-14 at 7 24 18 am

See the extra 2 and 1 being printed, before the 3, 2, 1 output in expected order?

getify commented 5 years ago

Here's another expression of (possibly) the same bug:

screen shot 2019-01-14 at 8 32 06 am

await; is not allowed, and should throw an exception, but RunJS just silently does nothing.

getify commented 5 years ago

Just FYI... I have babel transpilation turned off and this bug is still happening.

lukehaas commented 5 years ago

I'm able to replicate the extra console output. Looks like a bug, I will investigate further.

Regarding the await; It does complain if I have transpilation turned on but not if it is off. The only difference in the code is that the transpiled version has "use strict"; prepended to it.

getify commented 5 years ago

It's a syntax error regardless of strict mode or not. try it in a chrome console.

lukehaas commented 5 years ago

Indeed. I need to investigate further.

lukehaas commented 5 years ago

This has been a tough issue to solve but I believe I have a solution now. I'm going to write a few more test cases to make sure, and then push a release.

lukehaas commented 5 years ago

This is now resolved in version 1.2.1 Thanks again for raising this!

getify commented 5 years ago

Looks great, thanks!