wasmerio / wasmer-js

Monorepo for Javascript WebAssembly packages by Wasmer
https://wasmerio.github.io/wasmer-js/
MIT License
947 stars 83 forks source link

instance.wait() throws 'oneshot canceled` #443

Open ambrt opened 2 weeks ago

ambrt commented 2 weeks ago

Wasmer throws error in cowsay example

(...)
ERROR scheduler{thread_id=0}: wasmer_js::tasks::scheduler: An error occurred while handling a message error=__filename is not defined

(...)

Error: oneshot canceled
    at e.wbg.__wbg_new_28c511d9baebfa89 (file:///home/user/wasmer/examples/node_modules/@wasmer/sdk/dist/index.mjs:11:35384)
    at wasm://wasm/015c03b2:wasm-function[1466]:0x2fbfb8
    at wasm://wasm/015c03b2:wasm-function[7059]:0x424e95
    at wasm://wasm/015c03b2:wasm-function[277]:0xa5fbf
    at wasm://wasm/015c03b2:wasm-function[2038]:0x34ba1e
    at wasm://wasm/015c03b2:wasm-function[2897]:0x3ac776
    at wasm://wasm/015c03b2:wasm-function[9401]:0x44074e
    at v (file:///home/user/wasmer/examples/node_modules/@wasmer/sdk/dist/index.mjs:11:2534)
    at o (file:///home/user/wasmer/examples/node_modules/@wasmer/sdk/dist/index.mjs:11:2374)
    at node:internal/process/task_queues:151:7 {
  detailedMessage: 'oneshot canceled',
  causes: []
}

Script is:

import { init, Wasmer, initializeLogger } from "@wasmer/sdk/node";

async function run() {
  await init();

  let cowsay = await Wasmer.fromRegistry("cowsay");

  let instance = await cowsay.entrypoint.run({ args: ["hello world"] });
  const output = await instance.wait();

}
run();
g-linville commented 1 day ago

Getting the same error with this script, based on the example in the README:

import {init, Wasmer} from "@wasmer/sdk/node"

async function run() {
    await init()

    const pkg = await Wasmer.fromRegistry("python/python")
    const instance = await pkg.entrypoint.run({
        args: ["-c", "print('Hello, world!')"],
    })
    const { code, stdout } = await instance.wait()
    console.log(`Python exited with ${code}: ${stdout}`)
}

run()