{"record":{"id":"e2e0f08b9872746f","repo":"withastro/astro","slug":"language-does-not-exist-lang","errorCode":null,"errorMessage":"Language does not exist: ${lang}","messagePattern":"Language does not exist: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro-prism/src/loadLanguages-workerd.ts","lineNumber":78,"sourceCode":" * @returns {Promise<void>}\n */\nexport async function loadLanguages(languages: string | string[]) {\n\tprismRefCounter.increment();\n\n\tif (languages === undefined) {\n\t\tlanguages = Object.keys(components.languages).filter((l) => l !== 'meta');\n\t} else if (!Array.isArray(languages)) {\n\t\tlanguages = [languages];\n\t}\n\n\t// the user might have loaded languages via some other way or used `prism.js` which already includes some\n\t// we don't need to validate the ids because `getLoader` will ignore invalid ones\n\tconst loaded = [...loadedLanguages, ...Object.keys(Prism.languages)];\n\n\tawait getLoader(components, languages, loaded).load(async (lang: string) => {\n\t\tif (!(lang in components.languages)) {\n\t\t\tif (!loadLanguages.silent) {\n\t\t\t\tconsole.warn('Language does not exist: ' + lang);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// remove from Prism\n\t\tdelete Prism.languages[lang];\n\n\t\tif (Object.hasOwn(bundledLanguages, lang)) {\n\t\t\tawait bundledLanguages[lang]();\n\t\t}\n\n\t\tloadedLanguages.add(lang);\n\t}, loadChainer);\n\n\tprismRefCounter.decrement();\n}\n\n/**","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro-prism/src/loadLanguages-workerd.ts#L60-L96","documentation":"The workerd (Cloudflare runtime) build of astro-prism's language loader fetches Prism grammars on demand. When asked to load an id that is not present in prismjs' component index, it warns 'Language does not exist' and skips it — unless `loadLanguages.silent` is set. Highlighting for that language then falls back to plain text inside the code class.","triggerScenarios":"Calling `loadLanguages` with ids absent from prismjs' components.json; a languages config list reused between Node and Workers environments where the id resolves in one but not the other.","commonSituations":"Typos in configured language lists; prismjs versions lacking a newer grammar; shared highlight config between serverless runtimes.","solutions":["Verify the id exists in prismjs' components index (node_modules/prismjs/components.json) and fix the list","If unknown ids are intentional (custom pre-registered grammars), set `loadLanguages.silent = true` to suppress the warning","Register the custom grammar on Prism.languages before load so later code can still highlight it"],"exampleFix":"// before\nloadLanguages(['typescript', 'mylang']);\n\n// after\nPrism.languages['mylang'] = myGrammar; // pre-register\nloadLanguages(['typescript']);","handlingStrategy":"type-guard","validationCode":"// Validate the language list against prismjs' component index up front\nimport components from 'prismjs/components.json';\nconst known = (l: string) => l in components.languages;\nconst bad = requestedLanguages.filter((l) => !known(l) && !customRegistered.has(l));\nif (bad.length) throw new Error(`unknown prism languages: ${bad.join(', ')}`);","typeGuard":"const isLoadablePrismLanguage = (lang: string): boolean =>\n  lang !== 'meta' && lang in components.languages;","tryCatchPattern":null,"preventionTips":["Keep language lists per-runtime — do not share Node lists blindly with Workers builds","Set loadLanguages.silent = true only when unknown ids are expected and pre-registered","Pin prismjs versions so component ids stay stable"],"tags":["prism","workerd","cloudflare","syntax-highlighting"],"backgroundTag":"prism-language-unsupported","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}