bytecodealliance / bytecodealliance/wasmtime
p3(http): `request.new` transmission future resolves to `ok` when `client.send` fails
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 121
Description
Consider the following program:
```rust
use test_wasm32_wasip3::http::wasi::http::client;
use test_wasm32_wasip3::http::wasi::http::types::{
ErrorCode, Fields, Method, Request, Response, Scheme,
};
use test_wasm32_wasip3::http::wit_future;
use test_wasm32_wasip3::http::{export, exports::wasi::http::handler::Guest};
struct Component;
export!(Component);
impl Guest for Component {
async fn handle(_request: Request) -> Result {
let (trailers_tx, trailers_rx) = wit_future::new(|| Ok(None));
drop(trailers_tx);
let (request, sent) = Request::new(Fields::new(), None, trailers_rx, None);
request.set_method(&Method::Get).unwrap();
request.set_scheme(Some(&Scheme::Http)).unwrap();
request
.set_authority(Some("nonexistent.invalid:80"))
.unwrap();
request.set_path_with_query(Some("/")).unwrap();
client::send(request)
.await
.expect_err("send to an unresolvable authority should fail");
assert!(
sent.await.is_err(),
"a request that was never transmitted must not report successful transmission"
);
let (trailers_tx, trailers_rx) = wit_future::new(|| Ok(None));
drop(trailers_tx);
let (response, _sent) = Response::new(Fields::new(), None, trailers_rx);
response.set_status_code(200).unwrap();
Ok(response)
}
}
fn main() {
unreachable!("main is a stub");
}
```
It fails the following statement, using `wasmtime` `v46` and `main`:
```rust
assert!(
sent.await.is_err(),
"a request that was never transmitted must not report successful transmission"
);
```
#### Expected behavior
The spec for `request.new` [states](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit/types.wit#L307):
> The returned future resolves to result of transmission of this request
The returned future should resolve to an error, according to the spec.
Contributor guide
Assessment
This issue has not been assessed yet.