Revert WASM shared store execution model for now. JS Guests inexplicably get stuck.

This commit is contained in:
Sebastian Jeltsch
2026-02-27 21:36:31 +01:00
parent 09da29c69e
commit c14bc27772
+34 -20
View File
@@ -226,11 +226,11 @@ impl StoreBuilder<State> for Arc<SharedState> {
}
struct HttpStoreInternal {
store: Mutex<Store<State>>,
bindings: crate::host::Interfaces,
proxy_bindings: wasmtime_wasi_http::bindings::Proxy,
// store: Mutex<Store<State>>,
// bindings: crate::host::Interfaces,
// proxy_bindings: wasmtime_wasi_http::bindings::Proxy,
runtime_state: Arc<RuntimeInternal<Arc<SharedState>>>,
rt: Runtime,
}
#[derive(Clone)]
@@ -240,21 +240,22 @@ pub struct HttpStore {
impl HttpStore {
pub async fn new(rt: &Runtime) -> Result<Self, Error> {
let (mut store, bindings) = rt.new_bindings().await?;
let proxy_bindings = wasmtime_wasi_http::bindings::Proxy::instantiate_async(
&mut store,
&rt.state.component,
&rt.state.linker,
)
.await?;
// let (mut store, bindings) = rt.new_bindings().await?;
//
// let proxy_bindings = wasmtime_wasi_http::bindings::Proxy::instantiate_async(
// &mut store,
// &rt.state.component,
// &rt.state.linker,
// )
// .await?;
return Ok(Self {
state: Arc::new(HttpStoreInternal {
store: Mutex::new(store),
bindings,
proxy_bindings,
// store: Mutex::new(store),
// bindings,
// proxy_bindings,
runtime_state: rt.state.clone(),
rt: rt.clone(),
}),
});
}
@@ -263,13 +264,14 @@ impl HttpStore {
let state = self.state.clone();
return Self::call(&self.state.runtime_state, async move {
let api = state.bindings.trailbase_component_init_endpoint();
let (mut store, bindings) = state.rt.new_bindings().await?;
let api = bindings.trailbase_component_init_endpoint();
let args = Arguments {
version: args.version,
};
let mut store = state.store.lock().await;
// let mut store = state.store.lock().await;
store
.run_concurrent(async |accessor| -> Result<InitResult, Error> {
let (http, task_exit) = api.call_init_http_handlers(accessor, args.clone()).await?;
@@ -313,7 +315,15 @@ impl HttpStore {
// Depends on what the implementation does when the streaming body's receiving end gets
// out of scope.
let handle = tokio::spawn(async move {
let mut lock = state.store.lock().await;
// Instantiate a store per request, see FIXME below.
let (mut lock, _bindings) = state.rt.new_bindings().await?;
let proxy_bindings = wasmtime_wasi_http::bindings::Proxy::instantiate_async(
&mut lock,
&state.rt.state.component,
&state.rt.state.linker,
)
.await?;
// let mut lock = state.store.lock().await;
let req = lock.data_mut().new_incoming_request(
wasmtime_wasi_http::bindings::http::types::Scheme::Http,
@@ -322,8 +332,12 @@ impl HttpStore {
let out = lock.data_mut().new_response_outparam(sender)?;
state
.proxy_bindings
// FIXME: Using the shared store, this may not trigger the execution of JS guests.
// Rust guests don't have the same issue. Yet unclear what exactly is happening. Some
// incorrect termination?
// state
// .proxy_bindings
proxy_bindings
.wasi_http_incoming_handler()
.call_handle(lock.as_context_mut(), req, out)
.await