{"record":{"id":"87cdb8907c1333df","repo":"abhigyanpatwari/GitNexus","slug":"node-package-json-scan-of-reporoot-hit-the","errorCode":null,"errorMessage":"[node] package.json scan of ${repoRoot} hit the ${SCAN_MAX_DIRS}-directory cap; workspace packages below it will not resolve","messagePattern":"\\[node\\] package\\.json scan of (.+?) hit the (.+?)-directory cap; workspace packages below it will not resolve","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/import-resolvers/node-workspace-packages.ts","lineNumber":347,"sourceCode":"\n/**\n * Collect the `package.json` of every ADMITTED workspace package.\n *\n * Directory-only BFS: the sole files opened are manifests and the workspace\n * declaration, so this is far cheaper than the C# namespace scan next door,\n * which reads every `.cs` file.\n */\nexport async function loadNodeWorkspacePackages(\n  repoRoot: string,\n): Promise<NodeWorkspacePackages | null> {\n  const scope = await loadWorkspaceScope(repoRoot);\n  const byName = new Map<string, NodeWorkspacePackage>();\n  const queue: { dir: string; depth: number }[] = [{ dir: repoRoot, depth: 0 }];\n  let dirsScanned = 0;\n\n  while (queue.length > 0) {\n    if (dirsScanned >= SCAN_MAX_DIRS) {\n      logger.warn(\n        `[node] package.json scan of ${repoRoot} hit the ${SCAN_MAX_DIRS}-directory cap; workspace packages below it will not resolve`,\n      );\n      break;\n    }\n    const { dir, depth } = queue.shift()!;\n    dirsScanned++;\n\n    let entries: import('fs').Dirent[];\n    try {\n      entries = await fs.readdir(dir, { withFileTypes: true });\n    } catch {\n      continue;\n    }\n\n    for (const entry of entries) {\n      if (entry.isDirectory()) {\n        const childDir = path.join(dir, entry.name);\n        if (isHardcodedIgnoredDirectoryAtPath(repoRoot, childDir)) continue;","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/ingestion/import-resolvers/node-workspace-packages.ts#L329-L365","documentation":"loadNodeWorkspacePackages BFS-scans repoRoot for package.json manifests to enable workspace import resolution; the scan stopped after SCAN_MAX_DIRS (20,000) directories. Workspace packages located below the unscanned portion of the tree will not resolve, degrading import and call resolution for them.","triggerScenarios":"A monorepo (or a repo containing committed vendored trees) with more than 20,000 directories under the scan root — the cap trips before the whole tree is enumerated and the loop breaks.","commonSituations":"Huge pnpm/yarn workspaces; repos that accidentally commit node_modules or vendored SDKs; symptom is workspace:* imports in far-down packages failing to resolve to real symbols.","solutions":["Prune committed vendored trees / node_modules so the directory count drops under 20,000","Add ignore rules so large generated/vendor subtrees are excluded from the walk","Verify which packages failed to resolve and accept degraded resolution if the tree is legitimately above the cap"],"exampleFix":"# before — committed node_modules pushes repo to 45k dirs\nrepo/node_modules/**  (committed)\n\n# after — remove and ignore it\ngit rm -r --cached node_modules\necho 'node_modules/' >> .gitignore","handlingStrategy":"validation","validationCode":"import { readdirSync, statSync } from 'node:fs';\n\nfunction countDirs(root: string): number {\n  let n = 0;\n  const walk = (dir: string) => {\n    n++;\n    if (n > 20_000) return;\n    for (const e of readdirSync(dir, { withFileTypes: true })) {\n      if (e.isDirectory()) walk(`${dir}/${e.name}`);\n    }\n  };\n  walk(root);\n  return n;\n}\nif (countDirs(repoRoot) >= 20_000) {\n  throw new Error('directory count at/above the 20,000 scan cap — prune vendored trees or add ignore rules');\n}","typeGuard":"function withinScanCap(dirCount: number, cap = 20_000): boolean {\n  return dirCount < cap;\n}","tryCatchPattern":null,"preventionTips":["Never commit node_modules or large vendored SDK trees — they burn the 20,000-directory scan budget","Keep ignore rules current for generated/vendor directories so the walker prunes them before counting","After adding packages far down the tree, verify their workspace:* imports resolve; failure to resolve suggests the cap tripped"],"tags":["node","workspace","scan-limit","monorepo","import-resolution"],"backgroundTag":"scan-limit-exceeded","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}