Hey :wave: ,
I'm currently experimenting with jco
and I'm trying to import some lib into my js file, which is then bundled with esbuild --format esm
all is working fine for "simple" lib. But then when trying more complex one I'm sometimes hit by this problem. Right now I have this one to be precise
Caused by:
0: error while executing at wasm backtrace:
0: 0x78705a - <unknown>!<wasm function 9672>
1: 0x35239f - <unknown>!<wasm function 522>
2: 0xab1cb - <unknown>!<wasm function 79>
3: 0x3424ec - <unknown>!<wasm function 498>
4: 0x66ac8b - <unknown>!<wasm function 4035>
5: 0x625361 - <unknown>!<wasm function 3385>
6: 0x42288c - <unknown>!<wasm function 940>
7: 0x4225d9 - <unknown>!<wasm function 940>
8: 0x2d00c5 - <unknown>!<wasm function 358>
9: 0x1fc7d2 - <unknown>!<wasm function 186>
10: 0x50cf05 - <unknown>!<wasm function 1721>
11: 0x338556 - <unknown>!<wasm function 485>
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
1: Error: attempted to call an unknown imported function: 'wasi:random/random@0.2.0' 'get-random-u64'
Most of the time is just something not available in wasm which don't work but there the problem is different. So I'd just like to know a bit more on how to read the backtrace to checkout where in the bundle there is a problem so I can try and fix it.
Thanks in advance.
(I've already enabled the
const DEBUG_BINDINGS = true;)
Hey @kiwibe it seems like that last message is the one that matters, but it's weird because that function (get-randomu64
) is indeed in wasi:random@0.2.0
. What version of jco
are you using?
A minimal reproduction repo would certainly be helpful, if you can share some more code!
Hey @Victor Adossi I'll try to pull up a repro repo asap, but quick question on the side while I do this how could I know which line in my current JS could cause this error ?
So it could actually be any part of your code (or deps) that uses JS randomness functionality (i.e. Math.random()
) provided by the preview2 shim for NodeJS.
By default IIRC WASI random should be enabled by default, so you shouldn't have to do anything special for it.
Oh perfect thanks I see now where it's calling this I shall be able to put an example, as soon I'm off work I'll try to do it and share it with you thanks !
Yeah I'm going to try and see if I can reproduce with a little repo too!
Hey @kiwibe I'm not sure it'll help, but just to make sure Math.random
was working properly with currently released stuff I made a small example (jco
already has a great test suite so I didn't need to but just to have a self contained example you can compare to):
https://github.com/vados-cosmonic/jco-math-random-example
Hey sorry about my lag, i'm gonna give you a good reproduction soon but just to give you a bit more info the problem is originating form this line https://github.com/davidbau/seedrandom/blob/released/seedrandom.js#L219-L226
Thanks for looking into this -- interesting, I wouldn't expect Math.random()
to fail, but if the bug is there it should be really easy to reproduce.
As far as trying to get a small repro together, consider using one of the projects in this PR here -- they'll be in examples
soon enough!
Thanks a lot for being that responsive, I shall finally have more time to dig into that, this w-e but work is taking too much of my time right now.
Last updated: Nov 22 2024 at 16:03 UTC