scratchfoundation / scratch-gui

Graphical User Interface for creating and running Scratch 3.0 projects.
https://scratchfoundation.github.io/scratch-gui/develop/
BSD 3-Clause "New" or "Revised" License
4.46k stars 3.56k forks source link

Confusing runtime crash if scratch-vm uses `async` #5025

Open cwillisf opened 5 years ago

cwillisf commented 5 years ago

Expected Behavior

Using the async keyword in scratch-vm should either work correctly (requires changes in scratch-gui I believe) or it should be forbidden by lint and/or webpack rules (requires changes in scratch-vm).

Ideally, any error messages caused by using unsupported features should contain information about which unsupported feature was used, and where.

Actual Behavior

If async is used anywhere in scratch-vm then scratch-gui crashes at runtime with a message similar to Uncaught ReferenceError: regeneratorRuntime is not defined.

The message may appear immediately or may be delayed, depending on where the async keyword appears in the scratch-vm source code.

In some cases the error message may indicate the location of the async keyword but in my experience it usually indicates GUI.render with a deep React stack. The message doesn't contain any indication that the problem has anything to do with async, unsupported features, or anything like that which is especially problematic when the call stack doesn't indicate the correct location either.

Steps to Reproduce

  1. In scratch-vm:
    1. Place a line like this in just about any JavaScript file under src: const _foo = async function () { };
    2. Optionally, run npm run lint and note that there are no errors.
    3. Run npm run build or npm run watch to build the modified code. Note that there are no errors.
    4. Run npm link to register this copy of scratch-vm.
  2. In scratch-gui:
    1. Run npm link scratch-vm to link to the modified scratch-vm.
    2. Run npm start to start the webpack dev server.
    3. Visit http://localhost:8601/ in a browser, ideally with the dev console open.
    4. Observe the Uncaught ReferenceError: regeneratorRuntime is not defined error in the console. Depending on where the async keyword is, you may or may not also see the "Oops! Something went wrong." screen.
Przeblysk commented 4 years ago

same issue

apple502j commented 4 years ago

I think this is caused due to lack of babel-polyfill