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.
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.
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
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.
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"
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: Dec 23 2024 at 13:07 UTC