abhigyanpatwari/GitNexus · error · Error

Analyzer build scan exceeded depth ${limits.buildDepth}: ${a

Error message

Analyzer build scan exceeded depth ${limits.buildDepth}: ${absolutePath}

What it means

During the build-tree DFS, any subdirectory encountered at depth >= limits.buildDepth (default 128) triggers this error instead of being descended into. Depth is counted from the build root, so the guard bounds recursion through nested directories. An identity that silently truncated a deep tree would be wrong, so the scan fails closed.

Source

Thrown at gitnexus/src/core/analyzer-identity.ts:768

    const { absoluteDir, depth } = next;
    const directoryEntries = readDirectory(absoluteDir, options);
    scannedEntries += directoryEntries.length;
    if (scannedEntries > limits.buildEntries) {
      throw new Error(`Analyzer build scan exceeded ${limits.buildEntries} entries: ${buildRoot}`);
    }
    for (const entry of directoryEntries) {
      const absolutePath = path.join(absoluteDir, entry.name);
      const relativePath = path.relative(buildRoot, absolutePath).split(path.sep).join('/');
      const link = lstatSync(absolutePath, { bigint: true });
      if (link.isDirectory()) {
        entries.push({
          absolutePath,
          relativePath,
          kind: 'directory',
          state: statState(link),
        });
        if (depth >= limits.buildDepth) {
          throw new Error(
            `Analyzer build scan exceeded depth ${limits.buildDepth}: ${absolutePath}`,
          );
        }
        pending.push({ absoluteDir: absolutePath, depth: depth + 1 });
      } else if (link.isFile()) {
        const state = statState(link);
        scannedBytes += stateSize(state, absolutePath);
        if (scannedBytes > limits.buildBytes) {
          throw new Error(`Analyzer build scan exceeded ${limits.buildBytes} bytes: ${buildRoot}`);
        }
        entries.push({ absolutePath, relativePath, kind: 'file', state });
      } else if (link.isSymbolicLink()) {
        entries.push({ absolutePath, relativePath, kind: 'symlink', state: statState(link) });
      } else {
        throw new Error(`Unsupported analyzer build entry: ${absolutePath}`);
      }
    }
  }

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Find and flatten the offending chain: 'find dist -mindepth 128 -type d' shows what sits beyond the cap.
  2. Fix or exclude the generator producing >128-deep nesting in the build output.
  3. Clean and rebuild dist from scratch to drop accidentally nested artifacts.
  4. In tests, keep traversalLimits.buildDepth at or near the 128 default rather than tightening it below the fixture's real depth.
Defensive patterns

Strategy: try-catch

Type guard

function isBuildDepthLimitError(error: unknown): boolean {
  return error instanceof Error && /^Analyzer build scan exceeded depth \d+:/.test(error.message);
}

Try / catch

try {
  identity = resolveAnalyzerRunnerIdentity(import.meta.url);
} catch (error) {
  if (isBuildDepthLimitError(error)) {
    reportUserError('Build tree nesting exceeds 128 levels; flatten the generated output.');
  }
  throw error;
}

Prevention

When it happens

Trigger: collectBuildEntries descends a chain of nested directories 128+ levels deep under the analyzer's dist/src — typically generated code with pathological nesting (nested sourcemap output, recursively generated fixtures, or a build tool that mirrors package paths), or tests that set buildDepth to a small value via traversalLimits.

Common situations: Generated trees from tools that emit deeply nested output (bundlers mirroring node_modules scope chains, code generators); a locally built fork with accidentally recursive copy scripts; test fixtures exercising the limit with tight traversalLimits.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20). Data as JSON: /api/errors/e5b16be9ffefd735. Report an issue: GitHub.