deislabs / wagi

Write HTTP handlers in WebAssembly with a minimal amount of work
Apache License 2.0
889 stars 45 forks source link

`wasi_experimental_http::close` has not been defined #140

Closed baisijian closed 2 years ago

baisijian commented 2 years ago

hi : I compiled the source code get anerror: wasi_experimental_http::close has not been defined

itowlson commented 2 years ago

Hmm, I'm not able to reproduce that. Could you share more details please? E.g.

Thanks!

baisijian commented 2 years ago

Hmm, I'm not able to reproduce that. Could you share more details please? E.g.

  • what operating system are you on
  • what version of Rust are you on
  • what command are you using to build
  • is there any location information associated with the error

Thanks!

what operating system are you on linux what version of Rust are you on rustc 1.56.1 cargo 1.56.0 what command are you using to build run --package wagi --bin wagi -- -c examples/modules.toml is there any location information associated with the error image

itowlson commented 2 years ago

Okay, so it looks like wagi itself is compiling okay, but one of the Wasm modules referenced in examples/modules.toml is not working with the current version of the Wasm outbound HTTP proposal. In examples/modules.toml, could you try commenting out the example that makes an outbound HTTP request please?

# [[module]]
# route = "/http-example"
# module = "examples/http-example.wasm"
# allowed_hosts = ["https://api.brigade.sh"]
# http_max_concurrency = 2

and see if that helps? Thanks!

@radu-matei Do you know where this sample came from or if it is likely to need updating? It's been there since the year dot and I can't see the source code for it...

baisijian commented 2 years ago

Okay, so it looks like wagi itself is compiling okay, but one of the Wasm modules referenced in examples/modules.toml is not working with the current version of the Wasm outbound HTTP proposal. In examples/modules.toml, could you try commenting out the example that makes an outbound HTTP request please?

# [[module]]
# route = "/http-example"
# module = "examples/http-example.wasm"
# allowed_hosts = ["https://api.brigade.sh"]
# http_max_concurrency = 2

and see if that helps? Thanks!

@radu-matei Do you know where this sample came from or if it is likely to need updating? It's been there since the year dot and I can't see the source code for it...

yes,commenting out is working, thanks

radu-matei commented 2 years ago

@baisijian — thanks for pointing that out. We started putting together the Wagi examples in a single repo, but we never got around to adding all of them — see https://github.com/deislabs/wagi-examples

The HTTP example is mostly the same as — (with a main and proper content type headers) https://github.com/deislabs/wasi-experimental-http/blob/main/tests/rust/src/lib.rs#L3-L20

radu-matei commented 2 years ago

Reopening as this is an issue with the way Wagi instantiates modules. Thank you so much for the report, @baisijian.

So there are two places where prepare_wasm_instance gets called in Wagi — once in the handler, and once in the dispatcher. The dispatcher does not set the proper HTTP linker imports:

https://github.com/deislabs/wagi/blob/7d35f4fb4f7c6c710213f549b68a707d12bb33bf/src/dispatcher.rs#L321