Skip to content

Function not found, failed to find function export #12224

@LeoBorai

Description

@LeoBorai

Hi folks, I'm writing a solution to run WASM files using wasmtime, I use WIT to define a handler function which I'm expecting to call from my solution (host) through using wasmtime.

I have the following WIT definitions from the binary WASM file I've builded:

// ...
package wasi:random@0.2.6 {
  interface insecure-seed {
    insecure-seed: func() -> tuple<u64, u64>;
  }
}


package mate:runtime@0.1.0 {
  interface api {
    handler: async func(data: string) -> result<string, string>;
  }
}

The following code attempts to use the wasm_module, retrieves the function using get_typed_func::<(String,), (Result<String, String>,)> and runs it.

https://github.com/LeoBorai/mate/blob/29cd999d3190aece902d9dd79becd817c9afd639/src/runner/src/lib.rs#L46-L77

The name used for the function is the following:

https://github.com/LeoBorai/mate/blob/29cd999d3190aece902d9dd79becd817c9afd639/src/runner/src/lib.rs#L8-L10

When I try to run it I get the following error:

Error: Function 'mate:[email protected]/api#handler' not found

Caused by:
    failed to find function export

I have tried with different names:

  • Skipping package name: api#handler
  • Using function name directly: handler

But it fails with the same error.

Thanks in advance!

Reference Code

The whole implementation lies on this branch:

https://github.com/LeoBorai/mate/tree/1-async-wasm-execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions