Repository navigation
Sudden transpiled wasm component error in browser #634
Copy link
Copy link
Closed
Description
My team is seeing errors calling into transpiled wasm components in the browser (suddenly after months of no problems).
Here's a minimal env that reproduces the problem (for some of us):
https://github.com/James-Mart/minimal-transpile
Further context:
- My team uses a docker containerized dev environment (so the same env for all of us regardless of host), in yet we can't repro this issue across all our machines.
- I first saw this error (running a Mac M1 in case the host is relevant somehow). Mac up-to-date at v15.4.1. Up-to-date Docker Desktop 4.40.0 (187762)
- Reproed in browsers: Brave, LibreWolf, and Chrome (browsers running on host system accessing running app in container via a forwarded port)
- we also have a live server running our code (not the referenced minimal repro container). Serving/running the problematic code from that external backend does not produce this error for me (same browsers from same OS).
- In the referenced minimal env linked above, I see 2 different errors:
- when the wasm calls println!(), I see the following
> wasm.core.wasm:0x4da7 Uncaught RuntimeError: unreachable
at wasm.wasm.__rust_start_panic (wasm.core.wasm:0x4da7)
at wasm.wasm.rust_panic (wasm.core.wasm:0x4c1e)
at wasm.wasm._ZN3std9panicking20rust_panic_with_hook17h79071f5fb265d1d9E (wasm.core.wasm:0x4bf1)
at wasm.wasm._ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17h410c57f452410813E (wasm.core.wasm:0x3c9f)
at wasm.wasm._ZN3std3sys9backtrace26__rust_end_short_backtrace17h514500abf2a2d0caE (wasm.core.wasm:0x3c0b)
at wasm.wasm.rust_begin_unwind (wasm.core.wasm:0x4585)
at wasm.wasm._ZN4core9panicking9panic_fmt17he306018bf71f8e67E (wasm.core.wasm:0x9562)
at wasm.wasm._ZN3std2io5stdio6_print17h4ef99727a983bb66E (wasm.core.wasm:0x325e)
at wasm.wasm.hello (wasm.core.wasm:0x2c6)
at Module.Be (wasm.js:1:17452)
- when the wasm calls into rand and returns the result (no call to println!()), I get the following in the browser console
> assertion failed at adapter line
Ie @ wasm.js:1
$indirect-wasi:io/streams@0.2.3-[method]output-stream.blocking-write-and-flush @ wit-component:shim-f1fd1512:0x16a
$_ZN22wasi_snapshot_preview18bindings4wasi2io7streams12OutputStream24blocking_write_and_flush17h4f9b86b3d19bf6d5E @ wasm.core2.wasm:0x1154
$_ZN22wasi_snapshot_preview16macros5print17h319e9b3e6f2e5d09E @ wasm.core2.wasm:0x9ee
$_ZN22wasi_snapshot_preview16macros11assert_fail17h67fe26dc6b70f78bE @ wasm.core2.wasm:0x585
$cabi_import_realloc @ wasm.core2.wasm:0x641
Ee @ wasm.js:1
$indirect-wasi:random/random@0.2.3-get-random-bytes @ wit-component:shim-f1fd1512:0x176
$random_get @ wasm.core2.wasm:0x181a
$adapt-wasi_snapshot_preview1-random_get @ wit-component:shim-f1fd1512:0xb8
$_ZN3std3sys12thread_local6statik20LazyStorage$LT$T$GT$10initialize17h9d56f353d90c9518E @ wasm.core.wasm:0x1b09
$_ZN4rand4rngs6thread3rng17h1309d710195068edE @ wasm.core.wasm:0x1d18
$hello @ wasm.core.wasm:0x1641
Ze @ wasm.js:1
handleClick @ App.tsx:22
> 3 [repeated callstacks skipped]
> 7
> 6
> Uncaught RuntimeError: unreachable
at wit-component:adapter:wasi_snapshot_preview1._ZN22wasi_snapshot_preview16macros11assert_fail17h67fe26dc6b70f78bE (wasm.core2.wasm:0x58b)
at wit-component:adapter:wasi_snapshot_preview1.cabi_import_realloc (wasm.core2.wasm:0x641)
at Ee (wasm.js:1:16790)
at wit-component:shim.indirect-wasi:random/random@0.2.3-get-random-bytes (wit-component:shim-f1fd1512:0x176)
at wit-component:adapter:wasi_snapshot_preview1.random_get (wasm.core2.wasm:0x181a)
at wit-component:shim.adapt-wasi_snapshot_preview1-random_get (wit-component:shim-f1fd1512:0xb8)
at wasm.wasm._ZN3std3sys12thread_local6statik20LazyStorage$LT$T$GT$10initialize17h9d56f353d90c9518E (wasm.core.wasm:0x1b09)
at wasm.wasm._ZN4rand4rngs6thread3rng17h1309d710195068edE (wasm.core.wasm:0x1d18)
at wasm.wasm.hello (wasm.core.wasm:0x1641)
at Module.Ze (wasm.js:1:17825)
Important notes:
- This error is inconsistent on our machines. It always happens on my machine and another coworker's Mac M2. It does not happen at all on another coworker's Ubuntu machine. Again, all containerized regardless of host OS...
- On systems where it is reproducible, it's 100% of the time.
- No obvious change/variation in our tooling caused this. Then to repro, we each recreated the containerized env from scratch to run this test and got different results.
Reacted by Victor Adossi
Metadata
Metadata
Assignees
Labels
No labels
Activity
vados-cosmonic commentedon Apr 23, 2025
Seemingly related (From the Zulip discussion#jco > Sudden transpiled wasm component error in browser):
https://github.com/bytecodealliance/wasmtime/blob/4b6e96151f53705fc8c245e5d8efef31b0637eed/crates/wasi-preview1-component-adapter/src/lib.rs#L376
James-Mart commentedon Apr 25, 2025
build-artifacts.working.zip
build-artifacts.broken.zip
cool-ant commentedon Apr 26, 2025
Turns out to be a cargo-component issue. Moved to
bytecodealliance/cargo-component#398
vados-cosmonic commentedon Apr 26, 2025
Thanks @cool-ant ! There is the slight chance that something became more correct/fixed in the upstream, and some transpilation code needs to change. If that turns out to be the case we can re-open and keep digging/make changes to the transpilation process.