Stream: git-wasmtime

Topic: wasmtime / PR #14302 Adjust the recursive `run_concurrent...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:09):

alexcrichton requested dicej for a review on PR #14302.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:09):

alexcrichton opened PR #14302 from alexcrichton:fix-spin to bytecodealliance:main:

This commit adjust the previous check_recursive_run function found in concurrent.rs to instead be a check of the now-present event_loop_running bool. This allows disparate stores to run recursively as there should be no issue with that but still requires a single store just once and never recursively.

This was discovered in Spin's update to Wasmtime 49 at spinframework/spin#3710 where delegation of an HTTP request from a p3 component (executed with run_concurrent) to a p2 component (instantiated with instantiate_async) started panicking with this recursive check in Wasmtime 49. The cause of this was the refactoring in #14146 where all instantiation now simulates the concurrent event loop where enabled for the start function. Spin executes the components in different stores, however, which is how this commit fixes that case.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:09):

alexcrichton requested wasmtime-core-reviewers for a review on PR #14302.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:09):

alexcrichton commented on PR #14302:

FWIW this program:

use std::any::Any;
use wasmtime::component::{Component, InstancePre, Linker};
use wasmtime::{AsContext, Engine, Result, Store};

type Data = Option<Box<dyn Any + Send + Sync>>;

#[tokio::main]
async fn main() -> Result<()> {
    let engine = Engine::default();
    let component = Component::new(
        &engine,
        r#"
    (component
        (import "a" (func $a async))
        (core module $a
            (import "" "a" (func $a))
            (func (export "run") (call $a))
            (func (export "run2"))

            (func $f)
            (start $f)
        )
        (core func $a (canon lower (func $a)))
        (core instance $i (instantiate $a
            (with "" (instance
                (export "a" (func $a))
            ))
        ))

        (func (export "run") async (canon lift (core func $i "run")))
        (func (export "run2") (canon lift (core func $i "run2")))
    )
    "#,
    )?;

    let mut store = Store::<Data>::new(&engine, None);

    let mut linker = Linker::<Data>::new(&engine);
    linker.root().func_wrap_concurrent("a", |caller, ()| {
        Box::pin(async move {
            let (mut store, pre): (_, InstancePre<Data>) = caller.with(|caller| {
                let store = Store::<Data>::new(caller.as_context().engine(), None);
                let pre: InstancePre<Data> = caller
                    .as_context()
                    .data()
                    .as_ref()
                    .unwrap()
                    .downcast_ref::<InstancePre<Data>>()
                    .unwrap()
                    .clone();
                (store, pre)
            });
            let fut: std::pin::Pin<Box<dyn Future<Output = Result<_>> + Send + '_>> =
                Box::pin(pre.instantiate_async(&mut store));
            fut.await?;
            Ok(())
        })
    })?;

    let instance = linker.instantiate_async(&mut store, &component).await?;
    let run = instance.get_typed_func::<(), ()>(&mut store, "run")?;
    *store.data_mut() = Some(Box::new(linker.instantiate_pre(&component)?));
    store
        .run_concurrent(async |store| run.call_concurrent(store, ()).await)
        .await??;

    Ok(())
}

runs on 48.0.1 but fails on 49.0.0-rc.1 which is what I was testing with and is a rough reduction of what Spin is doing.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:12):

:thumbs_up: dicej submitted PR review:

Thanks for investigating and fixing this!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:22):

alexcrichton added PR #14302 Adjust the recursive run_concurrent check to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 20:49):

github-merge-queue[bot] removed PR #14302 Adjust the recursive run_concurrent check from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 08 2026 at 21:44):

github-actions[bot] added the label wasmtime:api on PR #14302.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 09 2026 at 04:04):

alexcrichton added PR #14302 Adjust the recursive run_concurrent check to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 09 2026 at 04:30):

:check: alexcrichton merged PR #14302.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 09 2026 at 04:30):

alexcrichton removed PR #14302 Adjust the recursive run_concurrent check from the merge queue.


Last updated: Sep 20 2026 at 18:08 UTC