← index #16890PR #14438
Related · high · value 2.727
QUERY · ISSUE

[webassembly] 'runPythonAsync' api missing { async: true } option.

openby Dreagonmonopened 2025-03-10updated 2026-03-24
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.

mergedby dpgeorgeopened 2024-05-07updated 2024-05-07
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().

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied