A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Migrate wasi-http to `wasmtime::error` (#12291)
Nick Fitzgerald85d8cc06d81d
diff --git a/Cargo.lock b/Cargo.lockindex f53774533e..cafb4c17d4 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -5109,7 +5109,6 @@ dependencies = [name = "wasmtime-wasi-http"version = "42.0.0"dependencies = [- "anyhow","async-trait","base64","bytes",diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.tomlindex 8e46aa4e51..f2c25fce70 100644--- a/crates/wasi-http/Cargo.toml+++ b/crates/wasi-http/Cargo.toml@@ -21,7 +21,6 @@ p3 = ["wasmtime-wasi/p3", "dep:tokio-util"]component-model-async = ["futures/alloc", "wasmtime/component-model-async"][dependencies]-anyhow = { workspace = true }async-trait = { workspace = true }bytes = { workspace = true }futures = { workspace = true, default-features = false }diff --git a/crates/wasi-http/src/body.rs b/crates/wasi-http/src/body.rsindex 0f3cb755b5..f93b6a59b3 100644--- a/crates/wasi-http/src/body.rs+++ b/crates/wasi-http/src/body.rs@@ -1,7 +1,6 @@//! Implementation of the `wasi:http/types` interface's various body types.use crate::{bindings::http::types, types::FieldMap};-use anyhow::anyhow;use bytes::Bytes;use http_body::{Body, Frame};use http_body_util::BodyExt;@@ -11,6 +10,7 @@ use std::mem;use std::task::{Context, Poll};use std::{pin::Pin, sync::Arc, time::Duration};use tokio::sync::{mpsc, oneshot};+use wasmtime::format_err;use wasmtime_wasi::p2::{InputStream, OutputStream, Pollable, StreamError};use wasmtime_wasi::runtime::{AbortOnDropJoinHandle, poll_noop};@@ -164,7 +164,7 @@ enum StreamEnd {pub struct HostIncomingBodyStream {state: IncomingBodyStreamState,buffer: Bytes,- error: Option<anyhow::Error>,+ error: Option<wasmtime::Error>,}impl HostIncomingBodyStream {@@ -613,7 +613,7 @@ impl OutputStream for BodyWriteStream {if let Some(written) = self.written.as_ref() {if !written.update(len) {let total = written.written();- return Err(StreamError::LastOperationFailed(anyhow!(+ return Err(StreamError::LastOperationFailed(format_err!(self.context.as_body_size_error(total))));}@@ -626,7 +626,7 @@ impl OutputStream for BodyWriteStream {// called. The call to `check_write` always guarantees that there's// at least one capacity if a write is allowed.Err(mpsc::error::TrySendError::Full(_)) => {- Err(StreamError::Trap(anyhow!("write exceeded budget")))+ Err(StreamError::Trap(format_err!("write exceeded budget")))}// Hyper is gone so this stream is now closed.diff --git a/crates/wasi-http/src/error.rs b/crates/wasi-http/src/error.rsindex 9c0a562b41..4279bd8483 100644--- a/crates/wasi-http/src/error.rs+++ b/crates/wasi-http/src/error.rs@@ -12,17 +12,17 @@ pub type HttpResult<T, E = HttpError> = Result<T, E>;/// Modeled after [`TrappableError`](wasmtime_wasi::TrappableError).#[repr(transparent)]pub struct HttpError {- err: anyhow::Error,+ err: wasmtime::Error,}impl HttpError {/// Create a new `HttpError` that represents a trap.- pub fn trap(err: impl Into<anyhow::Error>) -> HttpError {+ pub fn trap(err: impl Into<wasmtime::Error>) -> HttpError {HttpError { err: err.into() }}/// Downcast this error to an [`ErrorCode`].- pub fn downcast(self) -> anyhow::Result<ErrorCode> {+ pub fn downcast(self) -> wasmtime::Result<ErrorCode> {self.err.downcast()}diff --git a/crates/wasi-http/src/handler.rs b/crates/wasi-http/src/handler.rsindex 0f6335eae9..de875b0b53 100644--- a/crates/wasi-http/src/handler.rs+++ b/crates/wasi-http/src/handler.rs@@ -3,7 +3,6 @@#[cfg(feature = "p3")]use crate::p3;-use anyhow::{Result, anyhow};use futures::stream::{FuturesUnordered, StreamExt};use std::collections::VecDeque;use std::collections::btree_map::{BTreeMap, Entry};@@ -21,7 +20,7 @@ use std::time::{Duration, Instant};use tokio::sync::Notify;use wasmtime::AsContextMut;use wasmtime::component::Accessor;-use wasmtime::{Store, StoreContextMut};+use wasmtime::{Result, Store, StoreContextMut, format_err};/// Alternative p2 bindings generated with `exports: { default: async | store }`/// so we can use `TypedFunc::call_concurrent` with both p2 and p3 instances.@@ -174,7 +173,7 @@ pub trait HandlerState: 'static + Sync + Send {fn max_instance_concurrent_reuse_count(&self) -> usize;/// Called when a worker exits with an error.- fn handle_worker_error(&self, error: anyhow::Error);+ fn handle_worker_error(&self, error: wasmtime::Error);}struct ProxyHandlerInner<S: HandlerState> {@@ -446,9 +445,9 @@ whereaccessor.with(|mut access| write_profile(access.as_context_mut()));if timed_out {- Err(anyhow!("guest timed out"))+ Err(format_err!("guest timed out"))} else {- anyhow::Ok(())+ wasmtime::error::Ok(())}}));@@ -499,7 +498,7 @@ whereif sleep.as_mut().poll(cx).is_ready() {// Deadline has been reached; kill the instance with an// error.- return Poll::Ready(Err(anyhow!("guest timed out")));+ return Poll::Ready(Err(format_err!("guest timed out")));}}diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rsindex fe50030bb3..bcda1fe960 100644--- a/crates/wasi-http/src/lib.rs+++ b/crates/wasi-http/src/lib.rs@@ -65,7 +65,7 @@//! A standalone example of doing all this looks like://!//! ```no_run-//! use anyhow::bail;+//! use wasmtime::bail;//! use hyper::server::conn::http1;//! use std::sync::Arc;//! use tokio::net::TcpListener;@@ -292,7 +292,7 @@ use wasmtime::component::{HasData, Linker};/// }/// }/// ```-pub fn add_to_linker_async<T>(l: &mut wasmtime::component::Linker<T>) -> anyhow::Result<()>+pub fn add_to_linker_async<T>(l: &mut wasmtime::component::Linker<T>) -> wasmtime::Result<()>whereT: WasiHttpView + wasmtime_wasi::WasiView + 'static,{@@ -307,7 +307,7 @@ where/// example to avoid re-adding the same interfaces twice.pub fn add_only_http_to_linker_async<T>(l: &mut wasmtime::component::Linker<T>,-) -> anyhow::Result<()>+) -> wasmtime::Result<()>whereT: WasiHttpView + 'static,{@@ -368,7 +368,7 @@ impl<T: 'static> HasData for WasiHttp<T> {/// }/// }/// ```-pub fn add_to_linker_sync<T>(l: &mut Linker<T>) -> anyhow::Result<()>+pub fn add_to_linker_sync<T>(l: &mut Linker<T>) -> wasmtime::Result<()>whereT: WasiHttpView + wasmtime_wasi::WasiView + 'static,{@@ -381,7 +381,7 @@ where////// This is useful when using [`wasmtime_wasi::p2::add_to_linker_sync`] for/// example to avoid re-adding the same interfaces twice.-pub fn add_only_http_to_linker_sync<T>(l: &mut Linker<T>) -> anyhow::Result<()>+pub fn add_only_http_to_linker_sync<T>(l: &mut Linker<T>) -> wasmtime::Result<()>whereT: WasiHttpView + 'static,{diff --git a/crates/wasi-http/src/p3/body.rs b/crates/wasi-http/src/p3/body.rsindex c804307f78..e4e9f28547 100644--- a/crates/wasi-http/src/p3/body.rs+++ b/crates/wasi-http/src/p3/body.rs@@ -1,6 +1,5 @@use crate::p3::bindings::http::types::{ErrorCode, Fields, Trailers};use crate::p3::{WasiHttp, WasiHttpCtxView};-use anyhow::Context as _;use bytes::Bytes;use core::iter;use core::num::NonZeroUsize;@@ -18,6 +17,7 @@ use wasmtime::component::{Access, Destination, FutureConsumer, FutureReader, Resource, Source, StreamConsumer,StreamProducer, StreamReader, StreamResult,};+use wasmtime::error::Context as _;use wasmtime::{AsContextMut, StoreContextMut};/// The concrete type behind a `wasi:http/types.body` resource.diff --git a/crates/wasi-http/src/p3/host/handler.rs b/crates/wasi-http/src/p3/host/handler.rsindex 44f2c6aff0..6bf52e0445 100644--- a/crates/wasi-http/src/p3/host/handler.rs+++ b/crates/wasi-http/src/p3/host/handler.rs@@ -2,7 +2,6 @@ use crate::p3::bindings::http::handler::{Host, HostWithStore};use crate::p3::bindings::http::types::{ErrorCode, Request, Response};use crate::p3::body::{Body, BodyExt as _};use crate::p3::{HttpError, HttpResult, WasiHttp, WasiHttpCtxView};-use anyhow::Context as _;use core::task::{Context, Poll, Waker};use http_body_util::BodyExt as _;use std::sync::Arc;@@ -10,6 +9,7 @@ use tokio::sync::oneshot;use tokio::task::{self, JoinHandle};use tracing::debug;use wasmtime::component::{Accessor, Resource};+use wasmtime::error::Context as _;/// A wrapper around [`JoinHandle`], which will [`JoinHandle::abort`] the task/// when droppeddiff --git a/crates/wasi-http/src/p3/host/types.rs b/crates/wasi-http/src/p3/host/types.rsindex 9a81b051ee..35fdbdfdc7 100644--- a/crates/wasi-http/src/p3/host/types.rs+++ b/crates/wasi-http/src/p3/host/types.rs@@ -6,7 +6,6 @@ use crate::p3::bindings::http::types::{};use crate::p3::body::{Body, HostBodyStreamProducer};use crate::p3::{HeaderResult, HttpError, RequestOptionsResult, WasiHttp, WasiHttpCtxView};-use anyhow::Context as _;use core::mem;use core::pin::Pin;use core::task::{Context, Poll, ready};@@ -16,6 +15,7 @@ use tokio::sync::oneshot;use wasmtime::component::{Access, FutureProducer, FutureReader, Resource, ResourceTable, StreamReader,};+use wasmtime::error::Context as _;use wasmtime::{AsContextMut, StoreContextMut};fn get_fields<'a>(diff --git a/crates/wasi-http/src/p3/proxy.rs b/crates/wasi-http/src/p3/proxy.rsindex 74c2eb1564..eb08baa7d5 100644--- a/crates/wasi-http/src/p3/proxy.rs+++ b/crates/wasi-http/src/p3/proxy.rs@@ -1,8 +1,8 @@use crate::p3::WasiHttpView;use crate::p3::bindings::Proxy;use crate::p3::bindings::http::types::{ErrorCode, Request, Response};-use anyhow::Context as _;use wasmtime::component::{Accessor, TaskExit};+use wasmtime::error::Context as _;impl Proxy {/// Call `wasi:http/handler#handle` on [Proxy] getting a [Response] back.diff --git a/crates/wasi-http/src/p3/request.rs b/crates/wasi-http/src/p3/request.rsindex 00c56e787e..63072ff8e8 100644--- a/crates/wasi-http/src/p3/request.rs+++ b/crates/wasi-http/src/p3/request.rs@@ -484,12 +484,12 @@ pub async fn default_send_request(mod tests {use super::*;use crate::p3::DefaultWasiHttpCtx;- use anyhow::Result;use core::future::Future;use core::pin::pin;use core::str::FromStr;use core::task::{Context, Poll, Waker};use http_body_util::{BodyExt, Empty, Full};+ use wasmtime::Result;use wasmtime::{Engine, Store};use wasmtime_wasi::{ResourceTable, WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView};diff --git a/crates/wasi-http/src/p3/response.rs b/crates/wasi-http/src/p3/response.rsindex 5a835023ed..b0a33efe7f 100644--- a/crates/wasi-http/src/p3/response.rs+++ b/crates/wasi-http/src/p3/response.rs@@ -2,13 +2,13 @@ use crate::get_content_length;use crate::p3::bindings::http::types::ErrorCode;use crate::p3::body::{Body, GuestBody};use crate::p3::{WasiHttpCtxView, WasiHttpView};-use anyhow::Context as _;use bytes::Bytes;use http::{HeaderMap, StatusCode};use http_body_util::BodyExt as _;use http_body_util::combinators::UnsyncBoxBody;use std::sync::Arc;use wasmtime::AsContextMut;+use wasmtime::error::Context as _;/// The concrete type behind a `wasi:http/types.response` resource.pub struct Response {diff --git a/crates/wasi-http/src/types.rs b/crates/wasi-http/src/types.rsindex 61f4d0a9d1..253aad1ac3 100644--- a/crates/wasi-http/src/types.rs+++ b/crates/wasi-http/src/types.rs@@ -5,13 +5,13 @@ use crate::{bindings::http::types::{self, ErrorCode, Method, Scheme},body::{HostIncomingBody, HyperIncomingBody, HyperOutgoingBody},};-use anyhow::bail;use bytes::Bytes;use http_body_util::BodyExt;use hyper::body::Body;use hyper::header::HeaderName;use std::any::Any;use std::time::Duration;+use wasmtime::bail;use wasmtime::component::{Resource, ResourceTable};use wasmtime_wasi::p2::Pollable;use wasmtime_wasi::runtime::AbortOnDropJoinHandle;@@ -548,7 +548,7 @@ impl HostIncomingRequest {mut parts: http::request::Parts,scheme: Scheme,body: Option<HostIncomingBody>,- ) -> anyhow::Result<Self> {+ ) -> wasmtime::Result<Self> {let authority = match parts.uri.authority() {Some(authority) => authority.to_string(),None => match parts.headers.get(http::header::HOST) {@@ -673,7 +673,7 @@ pub type FieldMap = hyper::HeaderMap;/// A handle to a future incoming response.pub type FutureIncomingResponseHandle =- AbortOnDropJoinHandle<anyhow::Result<Result<IncomingResponse, types::ErrorCode>>>;+ AbortOnDropJoinHandle<wasmtime::Result<Result<IncomingResponse, types::ErrorCode>>>;/// A response that is in the process of being received.#[derive(Debug)]@@ -694,7 +694,7 @@ pub enum HostFutureIncomingResponse {/// The response is ready.////// An outer error will trap while the inner error gets returned to the guest.- Ready(anyhow::Result<Result<IncomingResponse, types::ErrorCode>>),+ Ready(wasmtime::Result<Result<IncomingResponse, types::ErrorCode>>),/// The response has been consumed.Consumed,}@@ -706,7 +706,7 @@ impl HostFutureIncomingResponse {}/// Create a new `HostFutureIncomingResponse` that is ready.- pub fn ready(result: anyhow::Result<Result<IncomingResponse, types::ErrorCode>>) -> Self {+ pub fn ready(result: wasmtime::Result<Result<IncomingResponse, types::ErrorCode>>) -> Self {Self::Ready(result)}@@ -716,7 +716,7 @@ impl HostFutureIncomingResponse {}/// Unwrap the response, panicking if it is not ready.- pub fn unwrap_ready(self) -> anyhow::Result<Result<IncomingResponse, types::ErrorCode>> {+ pub fn unwrap_ready(self) -> wasmtime::Result<Result<IncomingResponse, types::ErrorCode>> {match self {Self::Ready(res) => res,Self::Pending(_) | Self::Consumed => {diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rsindex 802e405e92..23d6979b2c 100644--- a/crates/wasi-http/src/types_impl.rs+++ b/crates/wasi-http/src/types_impl.rs@@ -7,10 +7,10 @@ use crate::types::{HostOutgoingRequest, HostOutgoingResponse, HostResponseOutparam, remove_forbidden_headers,};use crate::{HttpError, HttpResult, WasiHttpImpl, WasiHttpView, get_content_length};-use anyhow::{Context, anyhow};use std::any::Any;use std::str::FromStr;use wasmtime::component::{Resource, ResourceTable, ResourceTableError};+use wasmtime::{error::Context as _, format_err};use wasmtime_wasi::p2::{DynInputStream, DynOutputStream, DynPollable};impl<T> crate::bindings::http::types::Host for WasiHttpImpl<T>@@ -559,7 +559,7 @@ where_status: u16,_headers: Resource<Headers>,) -> HttpResult<()> {- Err(HttpError::trap(anyhow!("not implemented")))+ Err(HttpError::trap(format_err!("not implemented")))}}diff --git a/crates/wasi-http/tests/all/http_server.rs b/crates/wasi-http/tests/all/http_server.rsindex ce10353c7b..956c2097fc 100644--- a/crates/wasi-http/tests/all/http_server.rs+++ b/crates/wasi-http/tests/all/http_server.rs@@ -1,4 +1,3 @@-use anyhow::{Context, Result};use http::header::CONTENT_LENGTH;use hyper::service::service_fn;use hyper::{Request, Response};@@ -7,6 +6,7 @@ use std::net::{SocketAddr, TcpStream};use std::thread::JoinHandle;use tokio::net::TcpListener;use tracing::{debug, trace, warn};+use wasmtime::{Result, error::Context as _};use wasmtime_wasi_http::io::TokioIo;async fn test(diff --git a/crates/wasi-http/tests/all/p2.rs b/crates/wasi-http/tests/all/p2.rsindex bdf0946cea..6c7dbf4dd6 100644--- a/crates/wasi-http/tests/all/p2.rs+++ b/crates/wasi-http/tests/all/p2.rs@@ -1,6 +1,5 @@use crate::body;use crate::http_server::Server;-use anyhow::{Context, Result, anyhow};use futures::{FutureExt, channel::oneshot, future, stream};use http_body::Frame;use http_body_util::{BodyExt, Collected, Empty, StreamBody, combinators::BoxBody};@@ -9,8 +8,10 @@ use sha2::{Digest, Sha256};use std::{collections::HashMap, iter, net::Ipv4Addr, str, sync::Arc};use tokio::task;use wasmtime::{- Config, Engine, Store,+ Config, Engine, Result, Store,component::{Component, Linker, ResourceTable},+ error::Context as _,+ format_err,};use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView, p2::pipe::MemoryOutputPipe};use wasmtime_wasi_http::{@@ -123,7 +124,7 @@ async fn run_wasi_http(send_request: Option<RequestSender>,rejected_authority: Option<String>,early_drop: bool,-) -> anyhow::Result<Result<hyper::Response<Collected<Bytes>>, ErrorCode>> {+) -> wasmtime::Result<Result<hyper::Response<Collected<Bytes>>, ErrorCode>> {let stdout = MemoryOutputPipe::new(4096);let stderr = MemoryOutputPipe::new(4096);let table = ResourceTable::new();@@ -178,7 +179,7 @@ async fn run_wasi_http(.call_handle(&mut store, req, out).await?;- Ok::<_, anyhow::Error>(())+ Ok::<_, wasmtime::Error>(())});if let Some(r) = receiver {@@ -207,7 +208,7 @@ async fn run_wasi_http(}#[test_log::test(tokio::test)]-async fn wasi_http_proxy_tests() -> anyhow::Result<()> {+async fn wasi_http_proxy_tests() -> wasmtime::Result<()> {let req = hyper::Request::builder().header("custom-forbidden-header", "yes").uri("http://example.com:8080/test-path")@@ -263,7 +264,7 @@ async fn do_wasi_http_hash_all(override_send_request: bool) -> Result<()> {move |request: http::request::Parts| {if let (Method::GET, Some(body)) = (request.method, bodies.get(request.uri.path())) {- Ok::<_, anyhow::Error>(hyper::Response::new(body::full(Bytes::copy_from_slice(+ Ok::<_, wasmtime::Error>(hyper::Response::new(body::full(Bytes::copy_from_slice(body.as_bytes(),))))} else {@@ -318,7 +319,7 @@ async fn do_wasi_http_hash_all(override_send_request: bool) -> Result<()> {// Help rustc with type inference:if false {- return Ok::<_, anyhow::Error>(());+ return Ok::<_, wasmtime::Error>(());}}}@@ -360,17 +361,17 @@ async fn do_wasi_http_hash_all(override_send_request: bool) -> Result<()> {for line in body.lines() {let (url, hash) = line.split_once(": ")- .ok_or_else(|| anyhow!("expected string of form `<url>: <sha-256>`; got {line}"))?;+ .ok_or_else(|| format_err!("expected string of form `<url>: <sha-256>`; got {line}"))?;let path = url.strip_prefix(&prefix)- .ok_or_else(|| anyhow!("expected string with prefix {prefix}; got {url}"))?;+ .ok_or_else(|| format_err!("expected string with prefix {prefix}; got {url}"))?;let mut hasher = Sha256::new();hasher.update(bodies.get(path)- .ok_or_else(|| anyhow!("unexpected path: {path}"))?,+ .ok_or_else(|| format_err!("unexpected path: {path}"))?,);use base64::Engine;@@ -446,7 +447,7 @@ async fn wasi_http_double_echo() -> Result<()> {if let (&Method::POST, "/echo") =(request.method(), request.uri().path()){- Ok::<_, anyhow::Error>(hyper::Response::new(+ Ok::<_, wasmtime::Error>(hyper::Response::new(request.into_body().boxed(),))} else {@@ -467,7 +468,7 @@ async fn wasi_http_double_echo() -> Result<()> {// Help rustc with type inference:if false {- return Ok::<_, anyhow::Error>(());+ return Ok::<_, wasmtime::Error>(());}}}diff --git a/crates/wasi-http/tests/all/p2/async_.rs b/crates/wasi-http/tests/all/p2/async_.rsindex 8d94a011df..87caa9b3b7 100644--- a/crates/wasi-http/tests/all/p2/async_.rs+++ b/crates/wasi-http/tests/all/p2/async_.rs@@ -16,7 +16,7 @@ async fn run(path: &str, server: &Server) -> Result<()> {wasmtime_wasi_http::add_only_http_to_linker_async(&mut linker)?;let command = Command::instantiate_async(&mut store, &component, &linker).await?;let result = command.wasi_cli_run().call_run(&mut store).await?;- result.map_err(|()| anyhow::anyhow!("run returned an error"))+ result.map_err(|()| wasmtime::format_err!("run returned an error"))}#[test_log::test(tokio::test(flavor = "multi_thread"))]diff --git a/crates/wasi-http/tests/all/p2/sync.rs b/crates/wasi-http/tests/all/p2/sync.rsindex 849cf40564..5ac57caa42 100644--- a/crates/wasi-http/tests/all/p2/sync.rs+++ b/crates/wasi-http/tests/all/p2/sync.rs@@ -15,7 +15,7 @@ fn run(path: &str, server: &Server) -> Result<()> {wasmtime_wasi_http::add_only_http_to_linker_sync(&mut linker)?;let command = Command::instantiate(&mut store, &component, &linker)?;let result = command.wasi_cli_run().call_run(&mut store)?;- result.map_err(|()| anyhow::anyhow!("run returned an error"))+ result.map_err(|()| wasmtime::format_err!("run returned an error"))}#[test_log::test]diff --git a/crates/wasi-http/tests/all/p3/mod.rs b/crates/wasi-http/tests/all/p3/mod.rsindex 9dcc165b13..b1d8273f18 100644--- a/crates/wasi-http/tests/all/p3/mod.rs+++ b/crates/wasi-http/tests/all/p3/mod.rs@@ -1,6 +1,4 @@use crate::http_server::Server;-use anyhow::Result;-use anyhow::{Context as _, anyhow};use bytes::Bytes;use flate2::Compression;use flate2::write::{DeflateDecoder, DeflateEncoder};@@ -15,8 +13,8 @@ use test_programs_artifacts::*;use tokio::{fs, try_join};use wasm_compose::composer::ComponentComposer;use wasm_compose::config::{Config, Dependency, Instantiation, InstantiationArg};-use wasmtime::Store;use wasmtime::component::{Component, Linker, ResourceTable};+use wasmtime::{Result, Store, error::Context as _, format_err};use wasmtime_wasi::p3::bindings::Command;use wasmtime_wasi::{TrappableError, WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView};use wasmtime_wasi_http::p3::bindings::Proxy;@@ -116,7 +114,7 @@ impl WasiHttpView for Ctx {}}-async fn run_cli(path: &str, server: &Server) -> anyhow::Result<()> {+async fn run_cli(path: &str, server: &Server) -> wasmtime::Result<()> {let engine = test_programs_artifacts::engine(|config| {config.wasm_backtrace_details(wasmtime::WasmBacktraceDetails::Enable);config.async_support(true);@@ -145,14 +143,14 @@ async fn run_cli(path: &str, server: &Server) -> anyhow::Result<()> {.context("failed to call `wasi:cli/run#run`")?.context("guest trapped")?.0- .map_err(|()| anyhow!("`wasi:cli/run#run` failed"))+ .map_err(|()| format_err!("`wasi:cli/run#run` failed"))}async fn run_http<E: Into<ErrorCode> + 'static>(component_filename: &str,req: http::Request<impl Body<Data = Bytes, Error = E> + Send + Sync + 'static>,request_body_tx: oneshot::Sender<UnsyncBoxBody<Bytes, ErrorCode>>,-) -> anyhow::Result<Result<http::Response<Collected<Bytes>>, Option<ErrorCode>>> {+) -> wasmtime::Result<Result<http::Response<Collected<Bytes>>, Option<ErrorCode>>> {let engine = test_programs_artifacts::engine(|config| {config.wasm_backtrace_details(wasmtime::WasmBacktraceDetails::Enable);config.async_support(true);@@ -195,7 +193,7 @@ async fn run_http<E: Into<ErrorCode> + 'static>(let res = rx.await?;let (parts, body) = res.into_parts();let body = body.collect().await.context("failed to collect body")?;- anyhow::Ok(http::Response::from_parts(parts, body))+ wasmtime::error::Ok(http::Response::from_parts(parts, body))})?;@@ -203,55 +201,55 @@ async fn run_http<E: Into<ErrorCode> + 'static>(}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_get() -> anyhow::Result<()> {+async fn p3_http_outbound_request_get() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_GET_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_timeout() -> anyhow::Result<()> {+async fn p3_http_outbound_request_timeout() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_TIMEOUT_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_post() -> anyhow::Result<()> {+async fn p3_http_outbound_request_post() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_POST_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_large_post() -> anyhow::Result<()> {+async fn p3_http_outbound_request_large_post() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_LARGE_POST_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_put() -> anyhow::Result<()> {+async fn p3_http_outbound_request_put() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_PUT_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_invalid_version() -> anyhow::Result<()> {+async fn p3_http_outbound_request_invalid_version() -> wasmtime::Result<()> {let server = Server::http2(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_INVALID_VERSION_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_invalid_header() -> anyhow::Result<()> {+async fn p3_http_outbound_request_invalid_header() -> wasmtime::Result<()> {let server = Server::http2(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_INVALID_HEADER_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_unknown_method() -> anyhow::Result<()> {+async fn p3_http_outbound_request_unknown_method() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_UNKNOWN_METHOD_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_unsupported_scheme() -> anyhow::Result<()> {+async fn p3_http_outbound_request_unsupported_scheme() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_UNSUPPORTED_SCHEME_COMPONENT,@@ -261,31 +259,31 @@ async fn p3_http_outbound_request_unsupported_scheme() -> anyhow::Result<()> {}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_invalid_port() -> anyhow::Result<()> {+async fn p3_http_outbound_request_invalid_port() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_INVALID_PORT_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_invalid_dnsname() -> anyhow::Result<()> {+async fn p3_http_outbound_request_invalid_dnsname() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_INVALID_DNSNAME_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_response_build() -> anyhow::Result<()> {+async fn p3_http_outbound_request_response_build() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_RESPONSE_BUILD_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_content_length() -> anyhow::Result<()> {+async fn p3_http_outbound_request_content_length() -> wasmtime::Result<()> {let server = Server::http1(3)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_CONTENT_LENGTH_COMPONENT, &server).await}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn p3_http_outbound_request_missing_path_and_query() -> anyhow::Result<()> {+async fn p3_http_outbound_request_missing_path_and_query() -> wasmtime::Result<()> {let server = Server::http1(1)?;run_cli(P3_HTTP_OUTBOUND_REQUEST_MISSING_PATH_AND_QUERY_COMPONENT,@@ -295,7 +293,7 @@ async fn p3_http_outbound_request_missing_path_and_query() -> anyhow::Result<()>}#[test_log::test(tokio::test(flavor = "multi_thread"))]-async fn wasi_http_proxy_tests() -> anyhow::Result<()> {+async fn wasi_http_proxy_tests() -> wasmtime::Result<()> {let req = http::Request::builder().uri("http://example.com:8080/test-path").method(http::Method::GET);