facebook/docusaurus · error · Error

Docusaurus couldn't generate a unique hash for route ${route

Error message

Docusaurus couldn't generate a unique hash for route ${routeConfig.path} (level=${level} - index=${index}).\nThis is a bug, please report it here!\nhttps://github.com/facebook/docusaurus/issues/10718

What it means

Thrown by `generateUniqueRouteKey` when all three hash attempts collide with already-registered route keys. Docusaurus generates short hashes to name route chunks; if two routes produce identical hashes at every fallback length, the routing codegen cannot disambiguate them. The message explicitly says this is a bug to report at facebook/docusaurus#10718.

Source

Thrown at packages/docusaurus/src/server/codegen/codegenRoutes.ts:246

  } {
    const hashes = [
      // // OG algo to keep former snapshots
      () => simpleHash(JSON.stringify(routeConfig), 3),
      // Other attempts, not ideal but good enough
      // Technically we could use Math.random() here but it's annoying for tests
      () => simpleHash(`${level}${index}`, 3),
      () => simpleHash(JSON.stringify(routeConfig), 4),
      () => simpleHash(`${level}${index}`, 4),
    ];

    for (const tryHash of hashes) {
      const routeHash = tryHash();
      const routeKey = `${routePath}-${routeHash}`;
      if (!res.routesChunkNames[routeKey]) {
        return {routeKey, routeHash};
      }
    }
    throw new Error(
      `Docusaurus couldn't generate a unique hash for route ${routeConfig.path} (level=${level} - index=${index}).
This is a bug, please report it here!
https://github.com/facebook/docusaurus/issues/10718`,
    );
  }

  const {routeKey, routeHash} = generateUniqueRouteKey();

  res.routesChunkNames[routeKey] = {
    // Avoid clash with a prop called "component"
    ...genChunkNames({__comp: component}, 'component', component, res),
    ...(context &&
      genChunkNames({__context: context}, 'context', routePath, res)),
    ...genChunkNames(modules, 'module', routePath, res),
  };

  return serializeRouteConfig({
    routePath: routePath.replace(/'/g, "\\'"),

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Report the bug at https://github.com/facebook/docusaurus/issues/10718 with the route path, level, index, and Docusaurus version.
  2. As a workaround, slightly differentiate the colliding routes' configs (e.g. distinct `priority`, `metadata`, or path) so the JSON-hash fallback differs.
  3. Upgrade to the latest Docusaurus patch release — collision fixes may already be shipped.
  4. Reduce the number of generated routes (e.g. paginate, split into multiple plugin instances) to lower collision probability.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  return generateUniqueRouteKey();
} catch (e) {
  // log route + level + index and report upstream; do not silently retry
  throw e;
}

Prevention

When it happens

Trigger: Two or more routes with the same path and structurally similar config exhaust the 3 hash strategies (level+index hash, JSON-of-config hash, longer level+index hash). Extremely rare; the code comment links it to a known hash-collision issue.

Common situations: Sites with hundreds/thousands of auto-generated routes that happen to collide; unusual route config shapes that hash identically; observed after a Docusaurus upgrade that changed the hashing strategy.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/b118ab2d68ad3d6e. Report an issue: GitHub.