zed-industries/zed · error
Failed to create Wasmtime engine
Error message
Failed to create Wasmtime engine
What it means
One-time LazyLock panic while constructing the process-wide Wasmtime engine for tree-sitter WASM grammars. wasmtime::Engine::new with the default Config only fails on environmental problems — e.g., inability to map memory, incompatible CPU feature detection, or compilation backend initialization failure. Once it panics, every subsequent grammar load through this LazyLock re-poisons it.
Source
Thrown at crates/language/src/language.rs:167
});
// Tree-sitter auto-resets the parser at the end of a successful parse,
// but the cancellation paths (progress callback returning `Break`,
// cancelled balancing) leave outstanding state on the parser. The next
// call to `parse_with_options` would then *resume* that cancelled parse
// instead of starting fresh.
parser.reset();
parser.set_included_ranges(&[]).unwrap();
let result = func(&mut parser);
PARSERS.lock().push(parser);
result
}
pub fn with_query_cursor<F, R>(func: F) -> R
where
F: FnOnce(&mut QueryCursor) -> R,
{
let mut cursor = QueryCursorHandle::new();
func(cursor.deref_mut())
}
static WASM_ENGINE: LazyLock<wasmtime::Engine> = LazyLock::new(|| {
wasmtime::Engine::new(&wasmtime::Config::new()).expect("Failed to create Wasmtime engine")
});
/// A shared grammar for plain text, exposed for reuse by downstream crates.
pub static PLAIN_TEXT: LazyLock<Arc<Language>> = LazyLock::new(|| {
Arc::new(Language::new(
LanguageConfig {
name: "Plain Text".into(),
soft_wrap: Some(SoftWrap::EditorWidth),
autoclose_before: ")]}".into(),
matcher: (LanguageMatcher {
path_suffixes: vec!["txt".to_owned()],
first_line_pattern: None,
modeline_aliases: vec!["text".to_owned(), "txt".to_owned()],
})View on GitHub (pinned to 9d272b0363)
Solutions
- Log the wasmtime::Error to identify the environmental cause (memory limits, target features)
- Retry engine construction with a reduced/wasm engine config (e.g., disable parallel compilation or tune memory settings)
- If WASM grammars are unsupported in the environment, skip registering them instead of poisoning the global
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/language/src/language.rs:165 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/c8c036aac136458e.
Report an issue: GitHub.