-
Notifications
You must be signed in to change notification settings - Fork 6
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
Arrow function causes stack dump #96
Comments
I'll try to replicate this when I get home tonight. I do have a guess... Did you update your Moddable version recently? I did and started seeing stack dumps after upload. I didn't check to see if it was being caused by an arrow function, I just emptied out the $MODDABLE/build/tmp directory forcing everything to recompile and it worked. |
Looks like a real bug. Seems to be an interaction between top level await and the creation of arrow function. You can reproduce it without j5e in the simulator by changing helloworld/main.js to : class Button {}
const button = await new Button;
button.on = () => {}; We'll look into that. Meanwhile, you can work around the problem by wrapping the top-level module code in a function, which eliminates the top-level await. import Button from "j5e/button";
import LED from "j5e/led";
export default async function() {
const button = await new Button(device.pins.button);
const led = await new LED(device.pins.led);
button.on("open", () => {
trace("off\n");
led.stop().off();
});
} |
@phoddie works like a charm and as a bonus it stops linter from complaining about top level await. Thanks. |
Glad that helps. We'll get the problem fixed too -- that should work. FWIW - the reason that the Moddable SDK allows exporting a function from |
The problem has been fixed. It was in the parser, which likely means it has been around for a while. Nice find. Thank you! |
Thank you both! @barmichu TLA has reached stage 4 and we should see it implemented in ESLint soon so no more warnings there. Is that what you're using? |
@dtex thanks for the tip, that's good news. You are correct, I'm using ESLint with StandardJS style. I'm overwriting some rules tho i.e. semicolons :) |
Hi. I'm playing with j5e examples and I've noticed that using arrow function in event listener causes reboot loop and stack dump. Not sure if this should be reported here or in Moddable repo directly.
Code sample:
Console output after uploading:
Code works as expected when I change event listener to:
The text was updated successfully, but these errors were encountered: