Skip to content

Component causes panic in 0.14.0 but not in 0.13.0 #932

Description

@kevboh

Hello. I'm evaluating wasmex for a corporate project that involves running javascript compiled into wasm via Javy. I found that a very similar test component (one taken from the Javy documentation) causes a panic in 0.14.0 but runs fine in 0.13.0. The panic is:

thread 'wasmex-async' (108257044) panicked at /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wasmtime-wasi-39.0.1/src/runtime.rs:108:15:
                   Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.

I can't attach the .wasm file, but here are steps to repro, with code:

  1. Save index.js as
export function foo() {
  console.log("Hello from foo!");
}

console.log("Hello world!");

and index.wit as

package local:main;

world index-world {
  export foo: func();
}
  1. javy build index.js -C wit=index.wit -C wit-world=index-world -o index.wasm
  2. wasm-tools component embed index.wit index.wasm --world index-world -o index.embedded.wasm
  3. wasm-tools component new index.embedded.wasm --adapt wasi_snapshot_preview1.reactor.wasm -o index.component.wasm with the version-appropriate reactor.wasm from wasmtime

Then run the following:

Mix.install([{:wasmex, "0.14.0"}])
bytes = File.read!("index.component.wasm")
{:ok, pid} = Wasmex.Components.start_link(%{bytes: bytes, wasi: %Wasmex.Wasi.WasiP2Options{}})
{:ok, result} = Wasmex.Components.call_function(pid, "foo", [])

In 0.13.0 this will correctly log and return. In 0.14.0 it panics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions