Skip to content

test: Fix a race in composing components, add async-cross-component-await test - #1796

Open
cpetig wants to merge 2 commits into
bytecodealliance:mainfrom
cpetig:upstream-compose-race
Open

cpetig wants to merge 2 commits into
bytecodealliance:mainfrom
cpetig:upstream-compose-race

Conversation

@cpetig

@cpetig cpetig commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

AI;DR: This patch is part of a series of patches which are potentially interesting outside of my symmetric fork.

This one fixes a race condition in test file intermediate naming if you mix languages.

PS: Tell me if I should I remove claude from the commit messages.


The test harness composes every combination of test components (runner,
middle, leaf, ...). compose_wasm_with_wasm_compose writes the result of each
intermediate composition step to <runner>.composition{i}.wasm. Combinations
that share a runner are executed in parallel, so they overwrite each other's
intermediate file, which shows up as sporadic errors such as "malformed
section id" or "unexpected EOF" when composing. This was found while running
many component combinations with three components in a chain.

  • Commit 1 includes the names of all components of the combination in the
    intermediate file name, so it is unique per combination.
  • Commit 2 adds tests/runtime/async-cross-component-await: a
    runner -> middle -> leaf chain where the middle component awaits an async
    import from the leaf before returning its own result, written in Rust and C++
    for all three roles. With three components and two languages it has 8
    combinations, several of which share a runner, so it triggers the race
    reliably: without commit 1 it failed in each of 6 consecutive runs (4 of
    the 8 combinations each time), with it all 8 pass.

Tested with
cargo run -- test --languages rust,cpp --artifacts <dir> --rust-wit-bindgen-path ./crates/guest-rust tests/runtime/async-cross-component-await.

cpetig and others added 2 commits November 28, 2026 11:26
Combinations of test components that share a runner are composed in
parallel, but the intermediate file written by `wasm-compose` was named
only after the runner and the step. Concurrent combinations overwrote
each other's file, leading to sporadic "malformed section id" or
"unexpected EOF" errors. Include the names of all components of the
combination in the file name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exercise a chain of three components (runner -> middle -> leaf) where the
middle component awaits an async import from the leaf before returning
its own result, in both Rust and C++ for each of the three roles. This
covers async exports that suspend on an async import of another
component and are resumed by the event loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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