From f6d5cf102c8d61b8d32575dbd7a4d95090ce8c0d Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 00:41:43 +0000 Subject: [PATCH 1/2] fix(runtime): stop reporting readiness without an engine Built without the wasmtime-runtime feature, weft-runtime printed READY and exited without executing anything. weft-appd treats READY on the runtime's stdout as the readiness signal, so such a build made a session appear to start successfully although no component ran. The feature-disabled build now exits with an error naming the missing feature, so appd sees the runtime close without READY and stops the session. The binary still builds for the portable type, lint and unit checks. The Nix package keeps building the engine-enabled runtime. Validation: - new unit test: run_module in a feature-disabled build returns an error naming the feature; it fails against the previous stub - feature-disabled binary against a minimal package: exits 1 with the error and prints no READY - cargo test -p weft-runtime (5 passed), clippy -D warnings, fmt --check --- crates/weft-runtime/src/main.rs | 13 +++++++++++-- docs/building.md | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/weft-runtime/src/main.rs b/crates/weft-runtime/src/main.rs index bb74bfc..e50d4de 100644 --- a/crates/weft-runtime/src/main.rs +++ b/crates/weft-runtime/src/main.rs @@ -87,8 +87,9 @@ fn run_module( _preopen: &[(String, String)], _ipc_socket: Option<&str>, ) -> anyhow::Result<()> { - println!("READY"); - Ok(()) + anyhow::bail!( + "weft-runtime was built without the wasmtime-runtime feature and cannot execute components" + ) } #[cfg(feature = "wasmtime-runtime")] @@ -506,6 +507,14 @@ fn package_store_roots() -> Vec { mod tests { use super::*; + #[cfg(not(feature = "wasmtime-runtime"))] + #[test] + fn engine_disabled_build_refuses_to_run_components() { + let err = run_module(std::path::Path::new("app.wasm"), &[], None) + .expect_err("a build without wasmtime-runtime must not report success"); + assert!(err.to_string().contains("wasmtime-runtime")); + } + #[test] fn package_store_roots_includes_system_path() { let roots = package_store_roots(); diff --git a/docs/building.md b/docs/building.md index 96f1359..62d83a9 100644 --- a/docs/building.md +++ b/docs/building.md @@ -62,7 +62,7 @@ cargo build --release cargo build -p weft-runtime --features wasmtime-runtime,net-fetch ``` -Without `--features wasmtime-runtime`, the runtime prints READY and exits (stub mode, used in CI on platforms without Linux system dependencies). +Without `--features wasmtime-runtime`, the runtime compiles for type, lint and unit checks (the portable CI configuration) but exits with an error when asked to run a component; it never reports readiness. ## Signing packages From ca09b8ed909096f0445cb138848a50577ca0db54 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Fri, 9 Oct 2026 08:38:15 +0000 Subject: [PATCH 2/2] test(runtime): serialise tests that use WEFT_APP_STORE One test set WEFT_APP_STORE while another, running on a parallel thread, expected the default store roots, so the default-roots test failed intermittently (5 of 60 local runs, and in CI). The four tests that read or change the variable now share a lock, and the default-roots test clears the variable for its duration (0 of 30 runs fail). --- crates/weft-runtime/src/main.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/weft-runtime/src/main.rs b/crates/weft-runtime/src/main.rs index e50d4de..6d30105 100644 --- a/crates/weft-runtime/src/main.rs +++ b/crates/weft-runtime/src/main.rs @@ -507,6 +507,14 @@ fn package_store_roots() -> Vec { mod tests { use super::*; + /// Serialises the tests that read or change WEFT_APP_STORE; the test + /// harness runs tests on parallel threads that share the environment. + static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + + fn env_lock() -> std::sync::MutexGuard<'static, ()> { + ENV_LOCK.lock().unwrap_or_else(|p| p.into_inner()) + } + #[cfg(not(feature = "wasmtime-runtime"))] #[test] fn engine_disabled_build_refuses_to_run_components() { @@ -517,7 +525,14 @@ mod tests { #[test] fn package_store_roots_includes_system_path() { + let _env = env_lock(); + let prior = std::env::var_os("WEFT_APP_STORE"); + // SAFETY: env_lock serialises every test that touches the environment. + unsafe { std::env::remove_var("WEFT_APP_STORE") }; let roots = package_store_roots(); + if let Some(v) = prior { + unsafe { std::env::set_var("WEFT_APP_STORE", v) }; + } assert!( roots .iter() @@ -527,6 +542,7 @@ mod tests { #[test] fn package_store_roots_uses_weft_app_store_when_set() { + let _env = env_lock(); // SAFETY: test binary is single-threaded at this point. unsafe { std::env::set_var("WEFT_APP_STORE", "/custom/store") }; let roots = package_store_roots(); @@ -536,6 +552,7 @@ mod tests { #[test] fn resolve_package_finds_installed_package() { + let _env = env_lock(); use std::fs; let store = std::env::temp_dir().join(format!("weft_runtime_resolve_{}", std::process::id())); @@ -566,6 +583,7 @@ mod tests { #[test] fn resolve_package_errors_on_unknown_id() { + let _env = env_lock(); let store = std::env::temp_dir().join(format!("weft_runtime_resolve_empty_{}", std::process::id())); let _ = std::fs::create_dir_all(&store);