{"record":{"id":"c71a22ee71aed35f","repo":"mermaid-js/mermaid","slug":"failed-to-load-icon-set-data-prefix","errorCode":null,"errorMessage":"Failed to load icon set: ${data.prefix}","messagePattern":"Failed to load icon set: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/rendering-util/icons.ts","lineNumber":69,"sourceCode":"    throw new Error(`Invalid icon name: ${iconName}`);\n  }\n  const prefix = data.prefix || fallbackPrefix;\n  if (!prefix) {\n    throw new Error(`Icon name must contain a prefix: ${iconName}`);\n  }\n  let icons = iconsStore.get(prefix);\n  if (!icons) {\n    const loader = loaderStore.get(prefix);\n    if (!loader) {\n      throw new Error(`Icon set not found: ${data.prefix}`);\n    }\n    try {\n      const loaded = await loader();\n      icons = { ...loaded, prefix };\n      iconsStore.set(prefix, icons);\n    } catch (e) {\n      log.error(e);\n      throw new Error(`Failed to load icon set: ${data.prefix}`);\n    }\n  }\n  const iconData = getIconData(icons, data.name);\n  if (!iconData) {\n    throw new Error(`Icon not found: ${iconName}`);\n  }\n  return iconData;\n};\n\nexport const isIconAvailable = async (iconName: string) => {\n  try {\n    await getRegisteredIconData(iconName);\n    return true;\n  } catch {\n    return false;\n  }\n};\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/rendering-util/icons.ts#L51-L87","documentation":"Thrown by getRegisteredIconData when an async loader for the prefix was found but invoking it rejected/threw. The original error is logged via log.error(e) first, then this generic message is thrown wrapping the context (which prefix failed). The loaded JSON is cached into iconsStore only on success, so a failure leaves the pack unregistered and the next lookup retries the loader.","triggerScenarios":"A loader whose fetch/import throws: network failure on fetch('https://unpkg.com/.../icons.json'), a broken dynamic import path, the imported module not exposing `.icons`, or the resolver returning non-JSON. e.g. loader: () => import('@iconify-json/missing-pack').","commonSituations":"Offline/CORS-blocked CDN fetches, a typoed npm package name in the loader, an ESM/CJS interop where `module.icons` is undefined (then `{...undefined, prefix}` produces a bad pack that fails later), or a transient network error during lazy load.","solutions":["Check the console: log.error(e) prints the underlying cause (HTTP status, import error) immediately before this message.","Verify the loader actually resolves to an IconifyJSON object — for imports use .then((m) => m.icons), for fetch add .then((r) => r.json()).","Confirm network access/CORS for CDN loaders, and that the package is installed for bundler-based imports.","Add error handling inside the loader or fall back to a static `icons` pack if the async source is unreliable."],"exampleFix":"// before — import path wrong / no .icons\n{ name: 'logos', loader: () => import('@iconify-json/logos') }\n// after\n{\n  name: 'logos',\n  loader: () => import('@iconify-json/logos').then((m) => m.icons),\n}","handlingStrategy":"retry","validationCode":"async function safeLoad(prefix: string, loader: () => Promise<any>) {\n  try { return await loader(); }\n  catch (e) { console.error(`icon loader for ${prefix} failed`, e); throw e; }\n}","typeGuard":"function isIconifyJSON(x: any): x is { icons: Record<string, unknown>; prefix: string } {\n  return x && typeof x === 'object' && 'icons' in x;\n}","tryCatchPattern":"try { await getIconSVG(name); } catch (e) { if (/Failed to load icon set/.test(String(e))) { /* maybe retry once, or register a static pack */ } throw e; }","preventionTips":["Verify the loader resolves to IconifyJSON (m.icons for imports, r.json() for fetch).","Handle network errors in CDN loaders with a static-pack fallback.","Log the original error from log.error(e) to find the root cause."],"tags":["icons","network","iconify","async","loader"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}