mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 15:40:18 +00:00
fix: init WASM runtime eagerly regardless of tools directory existence (#401)
* fix: init WASM runtime eagerly regardless of tools directory existence The WASM tool runtime was only created at startup when both `wasm.enabled` and `wasm.tools_dir.exists()` were true. This meant that if the tools directory didn't exist yet (e.g. fresh deploy with `--no-onboard`), the runtime was set to None and passed to the ExtensionManager. Extensions installed later via the web UI would then fail with "WASM runtime not available" because the runtime could not be retroactively created. The Wasmtime engine initialization has no dependency on the tools directory — it only configures the compiler and starts an epoch ticker thread. The directory is only needed later when loading .wasm modules. Remove the directory check so the runtime is available for post-startup extension activation. Co-Authored-By: Claude Opus 4.6 <[email protected]> * test: add regression tests for WASM runtime eager init - runtime.rs: test_runtime_creation_without_tools_dir confirms the Wasmtime engine initialises without a tools directory on disk - manager.rs: test_activate_wasm_tool_with_runtime_passes_runtime_check verifies activation gets past the runtime check when a runtime is provided (fails on missing file, not missing runtime) - manager.rs: test_activate_wasm_tool_without_runtime_fails_with_runtime_error verifies the original error when no runtime is available Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: use idiomatic Result-to-Option conversion for WASM runtime init Address PR review feedback: replace match block with .map(Arc::new).map_err(|e| warn!(...)).ok() chain. Co-Authored-By: Claude Opus 4.6 <[email protected]> * style: fix formatting in extension manager tests Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3362081192
commit
7b883a02c0
+11
-13
@@ -402,19 +402,17 @@ impl AppBuilder {
|
||||
|
||||
let mcp_session_manager = Arc::new(McpSessionManager::new());
|
||||
|
||||
// Create WASM tool runtime
|
||||
let wasm_tool_runtime: Option<Arc<WasmToolRuntime>> =
|
||||
if self.config.wasm.enabled && self.config.wasm.tools_dir.exists() {
|
||||
match WasmToolRuntime::new(self.config.wasm.to_runtime_config()) {
|
||||
Ok(runtime) => Some(Arc::new(runtime)),
|
||||
Err(e) => {
|
||||
tracing::warn!("Failed to initialize WASM runtime: {}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
// Create WASM tool runtime eagerly so extensions installed after startup
|
||||
// (e.g. via the web UI) can still be activated. The tools directory is only
|
||||
// needed when loading modules, not for engine initialisation.
|
||||
let wasm_tool_runtime: Option<Arc<WasmToolRuntime>> = if self.config.wasm.enabled {
|
||||
WasmToolRuntime::new(self.config.wasm.to_runtime_config())
|
||||
.map(Arc::new)
|
||||
.map_err(|e| tracing::warn!("Failed to initialize WASM runtime: {}", e))
|
||||
.ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Load WASM tools and MCP servers concurrently
|
||||
let wasm_tools_future = {
|
||||
|
||||
Reference in New Issue
Block a user