microsoft/vscode · error · CopilotPromptLoadFailure

Could not load tree-sitter-${language}.wasm

Error message

Could not load tree-sitter-${language}.wasm

What it means

Error "Could not load tree-sitter-${language}.wasm" thrown in microsoft/vscode.

Source

Thrown at extensions/copilot/src/extension/completions-core/vscode-node/prompt/src/parse.ts:68

export function languageIdToWasmLanguage(languageId: string): WASMLanguage {
	if (!(languageId in languageIdToWasmLanguageMapping)) {
		throw new Error(`Unrecognized language: ${languageId}`);
	}
	return languageIdToWasmLanguageMapping[languageId];
}

const languageLoadPromises = new Map<WASMLanguage, Promise<Parser.Language>>();

async function loadWasmLanguage(language: WASMLanguage): Promise<Parser.Language> {
	// construct a path that works both for the TypeScript source, which lives under `/src`, and for
	// the transpiled JavaScript, which lives under `/dist`
	let wasmBytes;
	try {
		wasmBytes = await readFile(`tree-sitter-${language}.wasm`);
	} catch (e: unknown) {
		if (e instanceof Error && 'code' in e && typeof e.code === 'string' && e.name === 'Error') {
			throw new CopilotPromptLoadFailure(`Could not load tree-sitter-${language}.wasm`, e);
		}
		throw e;
	}
	return Parser.Language.load(wasmBytes);
}

export function getLanguage(language: string): Promise<Parser.Language> {
	const wasmLanguage = languageIdToWasmLanguage(language);

	if (!languageLoadPromises.has(wasmLanguage)) {
		// IMPORTANT: This function does not have an async signature to prevent interleaved execution
		// that can cause duplicate loading of the same language during yields/awaits prior to them
		// being added to the cache.
		const loadedLang = loadWasmLanguage(wasmLanguage);
		languageLoadPromises.set(wasmLanguage, loadedLang);
	}

	return languageLoadPromises.get(wasmLanguage)!;

View on GitHub (pinned to a94b963a32)

When it happens

Trigger: Thrown at extensions/copilot/src/extension/completions-core/vscode-node/prompt/src/parse.ts:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12). Data as JSON: /api/errors/99aeab082bb81552. Report an issue: GitHub.