Skip to content

Add async call stacks to the public API, use it in wasi:http#13510

Open
alexcrichton wants to merge 3 commits into
bytecodealliance:mainfrom
alexcrichton:wasi-http-changes
Open

Add async call stacks to the public API, use it in wasi:http#13510
alexcrichton wants to merge 3 commits into
bytecodealliance:mainfrom
alexcrichton:wasi-http-changes

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

This PR is intended to be the Wasmtime-specific resolution of WebAssembly/WASI#918, WebAssembly/WASI#919, and WebAssembly/WASI#920. Two commits are included here, both of which have more details as to what they're doing. At a high level though the first commit is providing the primitives in the wasmtime crate's API to reflect on the async call stack as defined by the component model. The second commit then refactors our wasmtime serve handling to thread this through and provide the host with a strong guarantee of "this request is being served on this store with this task", which is intended to then enable the store to do whatever it likes in terms of handling.

This commit adds a few new APIs to the surface area of the `wasmtime`
crate as well as reorganizes some internals. Namely:

* `StoreContextMut::async_call_stack` - yields an `Iterator` of the call
  stack of async tasks in the component model to understand the current
  call graph.

* `{Typed,}Func::{start,finish}_call_concurrent` - these new APIs allow
  splitting apart the previous `call_concurrent` function into discrete
  steps to learn about the task being created, notably the
  `GuestTaskId`. The previous `call_concurrent` is reimplemented in
  terms of these functions.

* Methods requiring the `component-model-async` Cargo feature are now
  under the `concurrent` module in `wasmtime` to cut down on `#[cfg]`
  required.

This is all intended to address the concerns of WebAssembly/WASI#918,
WebAssembly/WASI#919, and WebAssembly/WASI#920. This isn't plumbed into
wasi-http yet, but that'll come as a
This commit uses the previous commit to connect a generic, host-defined,
request ID and provide a strong connection to the `GuestTaskId` that's
being used to serve that request. This can be used by `wasi:http`
handlers to provide a strong correlation between outgoing requests, for
example, and incoming requests.
@alexcrichton alexcrichton requested review from a team as code owners May 29, 2026 19:48
@alexcrichton alexcrichton requested review from dicej and removed request for a team May 29, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant