QUERY · ISSUE
[webassembly] 'runPythonAsync' api missing { async: true } option.
bugport-webassembly
Port, board and/or hardware
webassembly standard build
MicroPython version
3.4.0; MicroPython v1.24.1 on 2025-03-09
Reproduction
const mp = await loadMicroPython();
await mp.runPythonAsync("import gc; gc.collect()");
Expected behaviour
In the web console, it should be no output, and the gc.collect() call succeed.
Observed behaviour
It raised an error in the web console
Aborted(Assertion failed: The call to mp_js_do_exec_async is running asynchronously. If this was intended, add the async option to the ccall/cwrap call.)
Additional Information
In the file ports/webassembly/api.js, int the runPythonAsync function, the Module.ccall missing the option { async: true }.
After adding that option to the ccall, it works as expected.
Code of Conduct
Yes, I agree
CANDIDATE · PULL REQUEST
webassembly/api: Resolve thenables returned from runPythonAsync.
port-webassembly
JavaScript semantics are such that the caller of an async function does not need to await that function for it to run to completion. This commit makes that behaviour also apply to top-level async Python code run via runPythonAsync().