Stream: git-wasmtime

Topic: wasmtime / issue #14218 wasi-http: p3 `Request::from_http...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2026 at 20:18):

andrewweston opened issue #14218:

Summary

p3::Request::from_http and p3::Response::from_http return

(Self, impl Future<Output = Result<(), Error>> + Send + 'static)

Under the Rust 2024 edition capture rules, the opaque return type implicitly captures the elided lifetime of the hooks: &mut dyn WasiHttpHooks parameter. The future's body never borrows hooks — it is only used synchronously (via FieldMap::new_immutable) before Self::new is called — but callers are constrained as if the borrow lived inside the future.

Present in wasmtime-wasi-http 48.0.1 and on main:

Why it matters

In the usual embedding, hooks live inside the store data behind WasiHttpView::http(), so the natural call site is inside a short-lived store access (e.g. Accessor::with under run_concurrent). The returned future then cannot escape the closure:

let (request, io) = store.with(|mut access| {
    let mut cx = access.as_context_mut();
    Request::from_http(cx.data_mut().http().hooks, req)
});
error[E0515]: cannot return value referencing function parameter `access`
note: this call may capture more lifetimes than intended, because Rust 2024
      has adjusted the `impl Trait` lifetime capture rules
help: if you can modify this crate, add a precise capturing bound to avoid
      overcapturing: `+ use<T>`

Suggested fix

Add precise-capture bounds so only the body type parameter is captured:

impl Future<Output = Result<(), Error>> + Send + 'static + use<T>

on both from_http functions (Request::new/Response::new are unaffected — they have no borrowed inputs).

Workaround

Decompose the request manually: build FieldMap::new_immutable(hooks, headers) inside the store access, then assemble with Request::new outside it.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2026 at 22:56):

rvolosatovs closed issue #14218:

Summary

p3::Request::from_http and p3::Response::from_http return

(Self, impl Future<Output = Result<(), Error>> + Send + 'static)

Under the Rust 2024 edition capture rules, the opaque return type implicitly captures the elided lifetime of the hooks: &mut dyn WasiHttpHooks parameter. The future's body never borrows hooks — it is only used synchronously (via FieldMap::new_immutable) before Self::new is called — but callers are constrained as if the borrow lived inside the future.

Present in wasmtime-wasi-http 48.0.1 and on main:

Why it matters

In the usual embedding, hooks live inside the store data behind WasiHttpView::http(), so the natural call site is inside a short-lived store access (e.g. Accessor::with under run_concurrent). The returned future then cannot escape the closure:

let (request, io) = store.with(|mut access| {
    let mut cx = access.as_context_mut();
    Request::from_http(cx.data_mut().http().hooks, req)
});
error[E0515]: cannot return value referencing function parameter `access`
note: this call may capture more lifetimes than intended, because Rust 2024
      has adjusted the `impl Trait` lifetime capture rules
help: if you can modify this crate, add a precise capturing bound to avoid
      overcapturing: `+ use<T>`

Suggested fix

Add precise-capture bounds so only the body type parameter is captured:

impl Future<Output = Result<(), Error>> + Send + 'static + use<T>

on both from_http functions (Request::new/Response::new are unaffected — they have no borrowed inputs).

Workaround

Decompose the request manually: build FieldMap::new_immutable(hooks, headers) inside the store access, then assemble with Request::new outside it.


Last updated: Aug 30 2026 at 09:07 UTC