abhigyanpatwari/GitNexus · error · Error

Analyzer runtime scan exceeded ${maxBytes} bytes: ${candidat

Error message

Analyzer runtime scan exceeded ${maxBytes} bytes: ${candidate}

What it means

The runtime scan keeps one cumulative byte budget (limits.runtimeBytes, default 2 GiB) shared across every package manifest, the lockfile, vendored grammar manifests, and hashed runtime payload files. Before each read, readStableFileWithinBudget() adds the candidate's stat size to the running total and throws when the sum would exceed the cap. This bounds how much filesystem content one identity computation can pull in, so a pathological install aborts instead of hashing unbounded bytes.

Source

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

function readStableFile(candidate: string): { bytes: Buffer; state: ReadableFileState } {
  for (let attempt = 0; attempt < 2; attempt += 1) {
    const before = snapshotReadableFile(candidate);
    const bytes = readFileSync(candidate);
    const after = snapshotReadableFile(candidate);
    if (isDeepStrictEqual(before, after)) return { bytes, state: after };
  }
  throw new Error(`Analyzer identity input changed while it was being read: ${candidate}`);
}

function readStableFileWithinBudget(
  candidate: string,
  budget: RuntimeArtifactScanBudget,
  maxBytes: number,
): { bytes: Buffer; state: ReadableFileState } {
  const before = snapshotReadableFile(candidate);
  const bytes = stateSize(before.target, candidate);
  if (budget.bytes + bytes > maxBytes) {
    throw new Error(`Analyzer runtime scan exceeded ${maxBytes} bytes: ${candidate}`);
  }
  const stable = readStableFile(candidate);
  budget.bytes += stable.bytes.length;
  return stable;
}

/** Hash a stable file through a fixed-size buffer instead of materializing it. */
function hashStableFile(candidate: string): {
  digest: string;
  state: ReadableFileState;
  bytes: number;
} {
  for (let attempt = 0; attempt < 2; attempt += 1) {
    const before = snapshotReadableFile(candidate);
    const expectedBytes = stateSize(before.target, candidate);
    let descriptor: number | null = null;
    try {
      descriptor = openSync(candidate, fsConstants.O_RDONLY);

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Prune the analyzer installation: remove stale vendored grammar copies, caches, and unused optional payloads from the gitnexus package tree.
  2. Reinstall gitnexus cleanly ('npm ci' in a fresh directory) so node_modules reflects the real dependency closure instead of accumulated cruft.
  3. Prefer a production install ('--omit=dev') for the environment running analysis to shrink the hashed runtime surface.
  4. If you pass traversalLimits in tests, verify runtimeBytes was not accidentally tightened below what the fixture needs.
  5. Report a bug upstream if a stock, freshly installed gitnexus still exceeds 2 GiB — the default is calibrated for real installs.
Defensive patterns

Strategy: try-catch

Type guard

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

Try / catch

try {
  identity = resolveAnalyzerRunnerIdentity(import.meta.url);
} catch (error) {
  if (isRuntimeScanBudgetError(error)) {
    throw new Error(`GitNexus install exceeds the 2 GiB identity scan budget; prune or reinstall it: ${error.message}`);
  }
  throw error;
}

Prevention

When it happens

Trigger: Called from readManifest (each runtime package's package.json), collectVendoredGrammarInputs, and the lockfile read; the same budget.bytes is also fed by hashed payload files in collectArtifacts. Fires when the analyzer installation's hashed content — typically large vendored tree-sitter grammars, native addons, Wasm modules, or an enormous dependency closure — pushes the cumulative total past 2 GiB. Note traversalLimits overrides can only tighten (Math.min against defaults), never raise this bound.

Common situations: A gitnexus install with unusually large vendored grammars or a huge transitive dependency tree (monorepo hoisted install, pnpm workspace linking many packages); a partially pruned install where stale payload duplicates accumulated; test harnesses that lowered runtimeBytes via traversalLimits and then hit their own tighter cap.

Related errors


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