{"record":{"id":"99aeab082bb81552","repo":"microsoft/vscode","slug":"could-not-load-tree-sitter-language-wasm","errorCode":null,"errorMessage":"Could not load tree-sitter-${language}.wasm","messagePattern":"Could not load tree-sitter-(.+?)\\.wasm","errorType":"exception","errorClass":"CopilotPromptLoadFailure","httpStatus":null,"severity":"error","filePath":"extensions/copilot/src/extension/completions-core/vscode-node/prompt/src/parse.ts","lineNumber":68,"sourceCode":"\nexport function languageIdToWasmLanguage(languageId: string): WASMLanguage {\n\tif (!(languageId in languageIdToWasmLanguageMapping)) {\n\t\tthrow new Error(`Unrecognized language: ${languageId}`);\n\t}\n\treturn languageIdToWasmLanguageMapping[languageId];\n}\n\nconst languageLoadPromises = new Map<WASMLanguage, Promise<Parser.Language>>();\n\nasync function loadWasmLanguage(language: WASMLanguage): Promise<Parser.Language> {\n\t// construct a path that works both for the TypeScript source, which lives under `/src`, and for\n\t// the transpiled JavaScript, which lives under `/dist`\n\tlet wasmBytes;\n\ttry {\n\t\twasmBytes = await readFile(`tree-sitter-${language}.wasm`);\n\t} catch (e: unknown) {\n\t\tif (e instanceof Error && 'code' in e && typeof e.code === 'string' && e.name === 'Error') {\n\t\t\tthrow new CopilotPromptLoadFailure(`Could not load tree-sitter-${language}.wasm`, e);\n\t\t}\n\t\tthrow e;\n\t}\n\treturn Parser.Language.load(wasmBytes);\n}\n\nexport function getLanguage(language: string): Promise<Parser.Language> {\n\tconst wasmLanguage = languageIdToWasmLanguage(language);\n\n\tif (!languageLoadPromises.has(wasmLanguage)) {\n\t\t// IMPORTANT: This function does not have an async signature to prevent interleaved execution\n\t\t// that can cause duplicate loading of the same language during yields/awaits prior to them\n\t\t// being added to the cache.\n\t\tconst loadedLang = loadWasmLanguage(wasmLanguage);\n\t\tlanguageLoadPromises.set(wasmLanguage, loadedLang);\n\t}\n\n\treturn languageLoadPromises.get(wasmLanguage)!;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microsoft/vscode/blob/a94b963a32aa9749d69504576791fa29700ae46d/extensions/copilot/src/extension/completions-core/vscode-node/prompt/src/parse.ts#L50-L86","documentation":"Error \"Could not load tree-sitter-${language}.wasm\" thrown in microsoft/vscode.","triggerScenarios":"Thrown at extensions/copilot/src/extension/completions-core/vscode-node/prompt/src/parse.ts:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"a94b963a32aa9749d69504576791fa29700ae46d","analyzedAt":"2026-08-12T01:08:56.794Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}