Skip to content
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

JavaScript errors in eventLoop.subscribe are not displayed #4071

Open
jamisonderek opened this issue Jan 16, 2025 · 0 comments
Open

JavaScript errors in eventLoop.subscribe are not displayed #4071

jamisonderek opened this issue Jan 16, 2025 · 0 comments
Assignees
Labels
Bug JS JS Runtime, loader and API

Comments

@jamisonderek
Copy link
Contributor

Describe the bug.

Any syntax errors inside callback functions will be silently ignored (calling invalid method, using == instead of ===, etc.) This makes troubleshooting difficult for the developer (and very difficult for people using AI to generate JavaScript).

Many JavaScript have the majority of the code inside of the eventLoop.subscribe handler (handling a user selection, periodic timer, etc.) so this is a fairly common issue to encounter when writing a complex script.

Reproduction

Repo
Save the below script to demo.js and copy the file onto Flipper Zero at SD Card/apps/Scripts/demo.js.

let eventLoop = require("event_loop");
function hi(_subscription, _item, event_loop) {
    print("Hi after 1337 ms");
    // This should throw an error
    event_loop.bad_method_name();
    print("bad_method_name called");
    event_loop.stop();
}

// This correctly displays an error on line 6 when the next line is uncommented.
// hi(1, 2, eventLoop); 

// BUG: This does NOT display error on line 6 & line 7 never executes.
eventLoop.subscribe(eventLoop.timer("oneshot", 1337), hi, eventLoop);

eventLoop.run();

print("finished");

On the Flipper run: Apps, Scripts, demo.js

Actual result from below script:
"Hi after 1337 ms"

Expected result from below script:
Hi after 1337 ms
--- ERROR ---
calling non-callable
at demo.js:5
see logs for full trace

Target

JavaScript

Logs

The log files also don't have any [E][JS] messages.

54892277 [I][Loader] Starting JS Runner
54892285 [I][AnimationManager] Unload animation 'L2_Secret_door_128x64'
54892330 [I][JS modules] Loading external module event_loop from /ext/apps_data/js_app/plugins/js_event_loop.fal
54892380 [I][Elf] Total size of loaded sections: 3772
54892381 [D][Fap] Library for js, API v. 1 loaded
54892382 [D][Fap] Library for js, API v. 1 loaded
54892382 [I][JS modules] Added module API to composite resolver: event_loop

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug JS JS Runtime, loader and API
Projects
None yet
Development

No branches or pull requests

3 participants