astrid-runtime/astrid · critical
failed to create wasmtime engine for hooks
Error message
failed to create wasmtime engine for hooks
What it means
`build_hook_engine` constructs the shared `wasmtime::Engine` for WASM hooks with the component model enabled, GC/exceptions disabled, and epoch interruption on. It panics if wasmtime cannot create the engine — an unrecoverable misconfiguration, since every hook handler depends on this engine.
Source
Thrown at crates/astrid-hooks/src/handler/wasm.rs:78
http.default_timeout_secs,
http.stream_connect_timeout_secs,
http.stream_read_timeout_secs,
http.header_deadline_secs,
http.max_redirects,
http.max_concurrent_streams,
http.max_response_bytes,
)
}
/// Build the hook engine with Astrid's explicit guest-feature boundary.
fn build_hook_engine() -> wasmtime::Engine {
let mut wt_config = wasmtime::Config::new();
wt_config
.wasm_component_model(true)
.wasm_gc(false)
.wasm_exceptions(false)
.epoch_interruption(true);
wasmtime::Engine::new(&wt_config).expect("failed to create wasmtime engine for hooks")
}
/// Handler for WASM components.
///
/// Lazily compiles the WASM component on first invocation and caches the
/// compiled [`Component`] (immutable, thread-safe) for subsequent calls.
/// A fresh [`Store`] is created for each invocation.
pub(crate) struct WasmHandler {
/// Cached wasmtime engine (shared across all components).
engine: wasmtime::Engine,
/// Cached compiled components (lazy-loaded, keyed by module path).
cached_components: Mutex<HashMap<String, Arc<Component>>>,
/// Configuration for WASM execution.
config: WasmConfig,
/// KV store for hook state (scoped to `hook:wasm`).
kv: Option<ScopedKvStore>,
/// Workspace root for file operations.
workspace_root: PathBuf,View on GitHub (pinned to affd8760f4)
Solutions
- Enable the required wasmtime Cargo features (e.g. `component-model`) so `wasm_component_model(true)` is supported.
- Check wasmtime release notes for config-option conflicts; remove options the new version rejects.
- Downgrade/upgrade the wasmtime crate to a version compatible with this configuration.
- Replace the expect with a `Result` return so host startup reports the underlying wasmtime error message.
Example fix
// before
wasmtime::Engine::new(&wt_config).expect("failed to create wasmtime engine for hooks")
// after
wasmtime::Engine::new(&wt_config)
.map_err(|e| HookError::EngineInit(format!("wasmtime engine init failed: {e}")))? Defensive patterns
Strategy: try-catch
Validate before calling
// Rust (build check): ensure the component-model feature is enabled cargo tree -e features | grep -q component-model || echo "wasmtime component-model feature missing"
Try / catch
// Rust: propagate engine init failure to callers
let engine = wasmtime::Engine::new(&wt_config)
.map_err(|e| HookError::EngineInit(e.to_string()))?; Prevention
- Pin wasmtime features in Cargo.toml and verify them in CI builds.
- Re-check Config options after every wasmtime upgrade against release notes.
- Add a smoke test that builds the engine at startup, not on first hook invocation.
- Prefer Result-returning constructors over expect for engine creation.
When it happens
Trigger: Calling `wasmtime::Engine::new(&wt_config)` with `wasm_component_model(true)` when the linked wasmtime build lacks component-model support (feature flags off), or when conflicting config options are set (e.g. GC disabled incompatibly with the component model on some wasmtime versions).
Common situations: Mismatches between Cargo feature flags and runtime config after a wasmtime version upgrade, a wasmtime build compiled without the `component-model` feature, or mutually exclusive config options introduced by a new wasmtime release.
Related errors
- build_host_state
- WASM capsule has no BLAKE3 hash in meta.json
- stability quantiles must lie strictly between zero and 10,00
- stability quantiles select duplicate boundary neighborhoods
- No Cargo build target selected. Set `[build] target = "wasm3
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/df876d6f3fb35b6d.
Report an issue: GitHub.