{"record":{"id":"ab32440166cfda69","repo":"abhigyanpatwari/GitNexus","slug":"analyzer-runtime-payload-scan-exceeded-depth-lim","errorCode":null,"errorMessage":"Analyzer runtime payload scan exceeded depth ${limits.runtimeDepth}: ${absolutePath}","messagePattern":"Analyzer runtime payload scan exceeded depth (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":1350,"sourceCode":"      const stat = lstatSync(absolutePath);\n      // Nested dependencies are collected from their manifests as separate\n      // packages. Only prune those separately traversed trees and VCS\n      // metadata; generic cache/model directories can contain loadable code,\n      // native addons, Wasm modules, or data consumed by the runtime.\n      //\n      // Pruning is decided by NAME alone. These four names never carry analyzer\n      // payload in any form: `node_modules` is traversed separately through\n      // `resolveDependencyPackageRoot` (which follows links and guards each\n      // hop), and a `.git`/`.hg`/`.svn` entry is VCS metadata whether it is a\n      // directory, a symbolic link into a shared store, or — inside a submodule\n      // or linked worktree checkout — a regular file holding a gitdir pointer.\n      // Hashing that pointer would make analyzer identity depend on where the\n      // checkout happens to live, which is a false-stale source, not a\n      // semantic input.\n      if (PRUNED_RUNTIME_DIRECTORIES.has(entry.name)) continue;\n      if (stat.isDirectory()) {\n        if (depth >= limits.runtimeDepth) {\n          throw new Error(\n            `Analyzer runtime payload scan exceeded depth ${limits.runtimeDepth}: ${absolutePath}`,\n          );\n        }\n        pending.push({ absoluteDir: absolutePath, depth: depth + 1 });\n      } else if (stat.isSymbolicLink() && !isFile(absolutePath)) {\n        // A symbolic link that does not resolve to a regular file must never\n        // reach the payload branch below: `snapshotReadableFile` stats the\n        // target, and a directory (or a dangling link) makes it throw, aborting\n        // the entire analyze. Workspace-linked checkouts made this reachable\n        // for every name, not just the pruned four — `dist -> build`, a\n        // vendored-grammar link, anything a sibling checkout ships.\n        //\n        // Such links are RECORDED by their link text rather than followed.\n        // Following them would (a) recurse without cycle protection — this\n        // traversal has none, so `self -> .` would ride the depth limit, which\n        // THROWS, trading one hard abort for another; (b) re-scan trees already\n        // reached by their real path, inflating the entry/byte budgets that\n        // also throw; and (c) need a whole containment/TOCTOU trust boundary","sourceCodeStart":1332,"sourceCodeEnd":1368,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/analyzer-identity.ts#L1332-L1368","documentation":"Thrown by collectArtifacts when a subdirectory would be enqueued at depth >= limits.runtimeDepth (default 64). The depth counter bounds symlink/cycle-induced recursion since this traversal has no visited-set; hitting the cap means the directory tree is deeper than 64 levels, which in practice signals a symlink cycle or an absurdly nested generated tree.","triggerScenarios":"collectArtifacts increments depth each time it pushes a child directory onto `pending`; if a directory at depth 64 still contains a subdirectory, the check `depth >= limits.runtimeDepth` fires on that child and the throw names the offending absolutePath.","commonSituations":"A symlink loop that does not resolve to a regular file but is itself reachable as a directory chain (e.g. self-referential or mutually-referential directory symlinks under a dependency); a deeply nested generated output like a sourcemap-of-sourcemap chain; a corrupt node_modules where a package re-installed itself recursively; very deep pnpm virtual-store paths combined with workspace nesting.","solutions":["Inspect the named absolutePath and its ancestors for a symlink cycle: `ls -la <absolutePath>` and walk up with `readlink -f`.","Repair node_modules: `rm -rf node_modules && npm install` (or pnpm/yarn equivalent) to remove the recursive structure.","If the depth is real (generated tree), flatten or relocate it outside the scanned root.","Confirm no `fs.symlink` in your build created a self-referential directory link."],"exampleFix":"// before: dist/.cache -> dist  (self-referential directory symlink)\n//   -> \"Analyzer runtime payload scan exceeded depth 64: /pkg/dist/.cache/x...\"\n//\n// after: remove the cycle\n//   $ find node_modules -type l -a -path '*dist*' -delete\n//   $ rm -rf node_modules && npm install","handlingStrategy":"try-catch","validationCode":"const { execSync } = require('node:child_process');\nfunction detectSymlinkCycle(packageRoot) {\n  try {\n    // find directory symlinks; a self/mutual reference indicates a cycle\n    execSync('find . -type l -xtype d', { cwd: packageRoot, stdio: ['ignore','pipe','ignore'] });\n  } catch { /* none */ }\n}\n// Or check depth explicitly:\nfunction maxDirDepth(packageRoot, hardStop = 70) {\n  const fs = require('node:fs'), path = require('node:path');\n  let max = 0;\n  function walk(d, depth) {\n    max = Math.max(max, depth);\n    if (depth >= hardStop) throw new Error(`Directory depth exceeds ${hardStop} at ${d}`);\n    for (const e of fs.readdirSync(d, { withFileTypes: true })) {\n      if (e.isDirectory() && !['node_modules','.git','.hg','.svn'].includes(e.name)) {\n        walk(path.join(d, e.name), depth + 1);\n      }\n    }\n  }\n  walk(packageRoot, 0);\n  return max;\n}","typeGuard":null,"tryCatchPattern":"try {\n  identity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);\n} catch (err) {\n  if (err.message.includes('runtime payload scan exceeded depth')) {\n    const p = err.message.split(': ').slice(1).join(': ');\n    log.error(`Directory tree too deep (or cycled) at ${p}; rebuild node_modules.`);\n  }\n  throw err;\n}","preventionTips":["Do not create self-referential or mutually-referential directory symlinks in your build output.","After install anomalies, run `rm -rf node_modules && npm install` to remove recursive structures.","Flatten deeply nested generated trees before invoking the analyzer.","Treat hitting the 64-depth cap as a defect signal (cycle or absurd nesting), not a normal limit to approach."],"tags":["analyzer-identity","filesystem","budget-limit","symlink-cycle"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}