-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling a rust program to wasm32-wasi
gives unknown import error
#3937
Comments
One of cloudevents' dependencies uses wasm-bindgen which requires you to run the wasm-bindegen tool over the wasm file. Wasm-bindgen is a tool to allow interaction between wasm and javascript (eg browser or nodejs). It does not work with wasm runtimes that don't use javascript like wasmtime. Note that cloudflare workers uses the v8 js engine to run wasm. |
Okay thanks! Does this mean that if I want to use wasmtime as the runtime, I can't use cloudevents-sdk crate anymore, right? |
I think so. |
Yes it looks like one of your dependency crates is using wasm-bindgen and wasm-bindgen injects imports into the wasm module which are expected to be filled in by JS but that's not happening here, hence the unknown import error. |
I have a similar issue. Using |
@Haishi2016 It's difficult to say without knowing more about your project. Could you file a new issue about this, and say more about how your project works and what dependencies you have? |
FYI there is a doc currently pointing to |
Thanks! #5394 is now a PR which updates that documentation. |
Hey there, I have the following module that tries to implement a handler function for export
It uses the cloudevents-sdk to deserialize the argument to a struct.
The wit file is extremely simple, just contains one handler function:
ce-handler: function(event: string) -> expected<string, error>
I am using the
wit-bindgen
tool for high level interface types.After I compiled the program to wasm module using
cargo build --target wasm32-wasi --release
, and then I tried to run this wasm module in thewasmtime
host (in python), and it outputs this runtime error:Any suggestions on how to understand this error message and hints on solve would be greatly appreciated!
The text was updated successfully, but these errors were encountered: