Stream: wit-bindgen

Topic: Issues importing some wasi interfaces


view this post on Zulip Hazel Rowell (Sep 18 2023 at 19:26):

Hey all!

I'm encountering an odd issue when adding imports for some wasi interfaces in my wit world, for example wasi:io/streams. I've run out of debugging ideas..

The error is being thrown when attempting to create the component using wasm-tools component new.

error: decoding custom section component-type:function-world

Caused by:
    0: record type must have at least one field (at offset 0xc)

and the world

world function-world {
  import wasi:clocks/wall-clock // this works!
  import wasi:io/streams // this produces the error

  use types.{http-request, http-response}

  export handle-request: func(req: http-request) -> http-response
}

Note: I am able to add use wasi:io/streams or use wasi:sockets/tcp Importing either creates the error .

Am I doing something wrong here? Looking though the tests / examples in github put me on the path of using import.

view this post on Zulip Guy Bedford (Sep 18 2023 at 19:28):

it looks like you might be using an older definition of wasi - the component model was updated to no longer support empty records, while older versions of wasi still had empty records in use.

view this post on Zulip Hazel Rowell (Sep 18 2023 at 19:41):

I see, thank you!

I'm pulling the wasi wits via wit-deps.

clocks = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
http = "https://github.com/WebAssembly/wasi-http/archive/main.tar.gz"

Searching though my deps folder and sure enough

...
interface streams {
    use wasi:poll/poll.{pollable}

    /// An error type returned from a stream operation. Currently this
    /// doesn't provide any additional information.
    record stream-error {}
...

I'll give the following a go and see how that works out
https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi

view this post on Zulip Hazel Rowell (Sep 18 2023 at 20:45):

I was able to resolve this by linking to the preview deps

preview = "https://gitpkg.now.sh/bytecodealliance/wasmtime/crates/wasi?e250334b8ebfba9359802ab7f61bdd7c6085d87a"

However, looking though the wits I'm getting the feeling I should just be avoiding relying on anything wasi until the component model stabilizes more.

view this post on Zulip Eduardo Rodrigues (Sep 18 2023 at 20:45):

i have been using GitPkg successfully to help point to a specific folder and commit hash. something like this:

wasi = "https://gitpkg.now.sh/bytecodealliance/wasmtime/crates/wasi?e250334b8ebfba9359802ab7f61bdd7c6085d87a"

view this post on Zulip Hazel Rowell (Sep 18 2023 at 20:46):

Eduardo Rodrigues said:

i have been using GitPkg successfully to help point to a specific folder and commit hash. something like this:

wasi = "https://gitpkg.now.sh/bytecodealliance/wasmtime/crates/wasi?e250334b8ebfba9359802ab7f61bdd7c6085d87a"

Just ended up with this same solution :smile:. Thank you!!


Last updated: Nov 22 2024 at 16:03 UTC