Closed yoshuawuyts closed 8 months ago
For wasm uploads we usually stick them in a .zip
. I think the restriction is related to CORS
I believe that this is an expected error related to the "protocol" that wasi-http is expecting. I can get your example to work by changing it to:
use wasi::http::{
outgoing_handler::{handle, OutgoingRequest},
types::{Fields, Method, RequestOptions, Scheme},
};
use wasi_http_client::Poller;
fn main() {
let mut poller = Poller::new();
let fields = Fields::new();
let req = OutgoingRequest::new(fields);
req.set_method(&Method::Get).unwrap();
req.set_scheme(Some(&Scheme::Https)).unwrap();
req.set_path_with_query(Some("/")).unwrap();
req.set_authority(Some("example.com")).unwrap();
let res = handle(req, None).unwrap();
let pollable = res.subscribe();
poller.insert(pollable);
// assert!(&pollable.ready(), "pollable was not ready");
poller.block_until();
drop(poller);
dbg!(res);
}
Specifically path_with_query
doesn't take the whole hostname, just the /
and the trailing bits. You'll also need to call set_authority
and set_scheme
. Finally the poller
is a "child resource" of res
so you'll need to drop that first before res
. After all that though I see:
[crates/wasi-http-client/examples/main.rs:21:5] res = FutureIncomingResponse {
handle: Resource {
handle: 0,
},
}
Due to this if you hit confusing errors I might also recommend WASMTIME_LOG=warn
to help diagnose a bit.
That did the trick; thank you!
I also came across this and wondered whether this is really the desired behavior.
Shouldn't handle
return an error code that can be handled in the user code instead of simply crashing?
That's a good point! @kaivol would you be up for opening a dedicated issue for that?
Yes I can do that See #8269
Test Case
GitHub doesn't like
.wasm
file uploads it seems:Steps to Reproduce
Using this branch of
yoshuawuyts/wasm-http-tools
:Expected Results
I expected this to run and not crash.
Actual Results
Versions and Environment
Wasmtime version or commit:
v18.0.1
Operating system: MacOS
Architecture: ARM
Extra Info
Talked to Dan; this seems like it might be an issue with the adapter? It's failing right in the middle. The
run.sh
command callswasmtime run -S http
- and perhaps that's not being picked up correctly in a CLI world? Unsure; we probably need to investigate.