fix: correct event loop starvation and memory leak in JS handler#32
Conversation
- Replace `JS_FreeAtom` loop with `JS_FreePropertyEnum` to fix memory leak when getting property names - Introduce `PollStatus` enum for `JsContext::poll` to properly differentiate between idle, executing jobs, and waiting for active timers - Use `isere_k_msleep` (wrapped Zephyr `k_msleep`) to yield the thread when timers are active instead of spinning aggressively and exhausting iterations, which prevents the OS from firing the timers - Print `JS_GetException` outputs during execution and evaluation functions to capture QuickJS exceptions and errors correctly
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Add missing `pull_request` triggers in `.github/workflows/ci.yml` so tests run on all PRs - Replace `JS_FreeAtom` loop with `JS_FreePropertyEnum` to fix memory leak when getting property names - Introduce `PollStatus` enum for `JsContext::poll` to properly differentiate between idle, executing jobs, and waiting for active timers - Use `isere_k_msleep` (wrapped Zephyr `k_msleep`) to yield the thread when timers are active instead of spinning aggressively and exhausting iterations, which prevents the OS from firing the timers - Print `JS_GetException` outputs during execution and evaluation functions to capture QuickJS exceptions and errors correctly
… into fix-event-loop-handler-16361771415626745393
The integration tests were previously failing due to multiple issues with the
eval_import_wrapperexecution and theJsContext::pollevent loop.handler.js), breaking async/await flows.src/js/context.rsto return aPollStatusenum frompoll()that enables the HTTP handler to know if it shouldcontinue(jobs were executed),isere_k_msleep(timers are waiting), orbreak(idle).handler_callbackfixed by replacing the loop callingqjs::JS_FreeAtomon each property with a final call toqjs::JS_FreePropertyEnumon the array to properly free the memory.printkviaqjs::JS_GetExceptionwhich greatly aids debugging.PR created automatically by Jules for task 16361771415626745393 started by @jeeyo