{"record":{"id":"c8c036aac136458e","repo":"zed-industries/zed","slug":"failed-to-create-wasmtime-engine","errorCode":null,"errorMessage":"Failed to create Wasmtime engine","messagePattern":"Failed to create Wasmtime engine","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/language/src/language.rs","lineNumber":167,"sourceCode":"    });\n    // Tree-sitter auto-resets the parser at the end of a successful parse,\n    // but the cancellation paths (progress callback returning `Break`,\n    // cancelled balancing) leave outstanding state on the parser. The next\n    // call to `parse_with_options` would then *resume* that cancelled parse\n    // instead of starting fresh.\n    parser.reset();\n    parser.set_included_ranges(&[]).unwrap();\n    let result = func(&mut parser);\n    PARSERS.lock().push(parser);\n    result\n}\n\npub fn with_query_cursor<F, R>(func: F) -> R\nwhere\n    F: FnOnce(&mut QueryCursor) -> R,\n{\n    let mut cursor = QueryCursorHandle::new();\n    func(cursor.deref_mut())\n}\n\nstatic WASM_ENGINE: LazyLock<wasmtime::Engine> = LazyLock::new(|| {\n    wasmtime::Engine::new(&wasmtime::Config::new()).expect(\"Failed to create Wasmtime engine\")\n});\n\n/// A shared grammar for plain text, exposed for reuse by downstream crates.\npub static PLAIN_TEXT: LazyLock<Arc<Language>> = LazyLock::new(|| {\n    Arc::new(Language::new(\n        LanguageConfig {\n            name: \"Plain Text\".into(),\n            soft_wrap: Some(SoftWrap::EditorWidth),\n            autoclose_before: \")]}\".into(),\n            matcher: (LanguageMatcher {\n                path_suffixes: vec![\"txt\".to_owned()],\n                first_line_pattern: None,\n                modeline_aliases: vec![\"text\".to_owned(), \"txt\".to_owned()],\n            })","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/language/src/language.rs#L149-L185","documentation":"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.","triggerScenarios":"Thrown at crates/language/src/language.rs:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}