{"record":{"id":"f43292254412833d","repo":"abhigyanpatwari/GitNexus","slug":"analyzer-runtime-scan-exceeded-maxbytes-bytes","errorCode":null,"errorMessage":"Analyzer runtime scan exceeded ${maxBytes} bytes: ${candidate}","messagePattern":"Analyzer runtime scan exceeded (.+?) bytes: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":538,"sourceCode":"function readStableFile(candidate: string): { bytes: Buffer; state: ReadableFileState } {\n  for (let attempt = 0; attempt < 2; attempt += 1) {\n    const before = snapshotReadableFile(candidate);\n    const bytes = readFileSync(candidate);\n    const after = snapshotReadableFile(candidate);\n    if (isDeepStrictEqual(before, after)) return { bytes, state: after };\n  }\n  throw new Error(`Analyzer identity input changed while it was being read: ${candidate}`);\n}\n\nfunction readStableFileWithinBudget(\n  candidate: string,\n  budget: RuntimeArtifactScanBudget,\n  maxBytes: number,\n): { bytes: Buffer; state: ReadableFileState } {\n  const before = snapshotReadableFile(candidate);\n  const bytes = stateSize(before.target, candidate);\n  if (budget.bytes + bytes > maxBytes) {\n    throw new Error(`Analyzer runtime scan exceeded ${maxBytes} bytes: ${candidate}`);\n  }\n  const stable = readStableFile(candidate);\n  budget.bytes += stable.bytes.length;\n  return stable;\n}\n\n/** Hash a stable file through a fixed-size buffer instead of materializing it. */\nfunction hashStableFile(candidate: string): {\n  digest: string;\n  state: ReadableFileState;\n  bytes: number;\n} {\n  for (let attempt = 0; attempt < 2; attempt += 1) {\n    const before = snapshotReadableFile(candidate);\n    const expectedBytes = stateSize(before.target, candidate);\n    let descriptor: number | null = null;\n    try {\n      descriptor = openSync(candidate, fsConstants.O_RDONLY);","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/analyzer-identity.ts#L520-L556","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Prune the analyzer installation: remove stale vendored grammar copies, caches, and unused optional payloads from the gitnexus package tree.","Reinstall gitnexus cleanly ('npm ci' in a fresh directory) so node_modules reflects the real dependency closure instead of accumulated cruft.","Prefer a production install ('--omit=dev') for the environment running analysis to shrink the hashed runtime surface.","If you pass traversalLimits in tests, verify runtimeBytes was not accidentally tightened below what the fixture needs.","Report a bug upstream if a stock, freshly installed gitnexus still exceeds 2 GiB — the default is calibrated for real installs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isRuntimeScanBudgetError(error: unknown): boolean {\n  return error instanceof Error && /^Analyzer runtime scan exceeded \\d+ bytes:/.test(error.message);\n}","tryCatchPattern":"try {\n  identity = resolveAnalyzerRunnerIdentity(import.meta.url);\n} catch (error) {\n  if (isRuntimeScanBudgetError(error)) {\n    throw new Error(`GitNexus install exceeds the 2 GiB identity scan budget; prune or reinstall it: ${error.message}`);\n  }\n  throw error;\n}","preventionTips":["Install gitnexus with --omit=dev in analysis environments to keep the hashed runtime surface small.","Do not park caches, models, or build artifacts inside the gitnexus package tree.","Reinstall from the published package rather than letting installs accumulate payload cruft."],"tags":["gitnexus","analyzer-identity","budget","filesystem","limits"],"backgroundTag":"scan-budget-exceeded","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}