← index #17839Issue #17657
Related · high · value 0.584
QUERY · ISSUE

webassembly: registerJsModule apparently broken

openby WebReflectionopened 2025-08-05updated 2025-08-27
bugport-webassembly

Port, board and/or hardware

webassembly

MicroPython version

latest webassembly pyscript port published on npm

Reproduction

interpreter.registerJsModule('reg_mod', { Anything: function () {} });
from reg_mod import Anything
from reg_mod import Anything
from reg_mod import Anything

This would throw an error about being unable to import Anything from reg_mod

Expected behaviour

Code that was correctly registering from JS namespaces/modules should work as it did before.

Observed behaviour

in latest preview build, differently from 386 one, everything registered via runtime.registerJsModule(...) is not exposed, usable, or reachable from within the Python code.

I am not sure this is a regression introduced by latest changes around identity, but it basically blocks us from updating MicroPython to its latest.

/cc @dpgeorge @ntoll

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

webassembly: getting JS symbols implicitly also throws errors

closedby WebReflectionopened 2025-07-10updated 2025-07-17
bugport-webassembly

Port, board and/or hardware

webassembly

MicroPython version

MicroPython webassembly latest from npm

Reproduction

In here we solved the in operation check https://github.com/micropython/micropython/pull/17604 but if any libraries tries to read the stringified version of a reference we have the same issue via the get proxy trap.

function test(value) {
  return Object.prototype.toString.call(value);
}
import js
js.test({})

Result:

RuntimeError: Aborted(Assertion failed: stringToUTF8Array expects a string (got symbol))

Expected behaviour

We covered Symbol.iterator we should cover also Symbol.toStringTag as that's implicitly retrieved when Object.prototype.toString.call(ref) happens, which is a very common way to retrieve the kind of the reference as it returns:

  • [object Object]
  • [object Array]
  • [object Null]
  • [object Function]
  • [object Anything]

This practice is particularly useful when unknown kinds are around and any serializer would like to guess how to handle these, and it's currently breaking a specific PyScript use case which is also pretty common when used in IoT contrained environments.

Observed behaviour

An error is throws every single time.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

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