{"record":{"id":"11c0093df7a74f93","repo":"abhigyanpatwari/GitNexus","slug":"analyzer-dependency-runtime-changed-while-its-iden","errorCode":null,"errorMessage":"Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}","messagePattern":"Analyzer dependency runtime changed while its identity was being computed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2742,"sourceCode":"    runtimeVariant,\n  );\n\n  const packageVersion = dependencyInputs.packages[0]?.manifest.version;\n  if (typeof packageVersion !== 'string' || packageVersion.trim() === '') {\n    throw new Error(`GitNexus package version is unavailable in ${packageRoot}`);\n  }\n\n  const buildSnapshotAfter = buildSnapshot(\n    collectBuildEntries(buildRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(build.snapshot, buildSnapshotAfter)) {\n    throw new Error(`Analyzer build changed while its identity was being computed: ${buildRoot}`);\n  }\n  const dependencySnapshotAfter = dependencySnapshot(\n    collectDependencyInputs(packageRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(dependencySnapshotBefore, dependencySnapshotAfter)) {\n    throw new Error(\n      `Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}`,\n    );\n  }\n\n  const nextCache: IdentityCachePayload = {\n    schemaVersion: IDENTITY_CACHE_SCHEMA_VERSION,\n    packageRoot,\n    buildRoot,\n    packageVersion,\n    buildKind: kind,\n    buildCanonicalization: BUILD_CANONICALIZATION,\n    dependencyCanonicalization: DEPENDENCY_RUNTIME_CANONICALIZATION,\n    traversalLimits,\n    runtimeVariant,\n    buildRootState: build.rootState,\n    buildDigest: build.digest,\n    buildEntries: build.entries,\n    buildDirectoryGuards: build.directoryGuards,","sourceCodeStart":2724,"sourceCodeEnd":2760,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/analyzer-identity.ts#L2724-L2760","documentation":"Thrown by resolveAnalyzerRunnerIdentity when the dependency-runtime snapshot changed between the start of identity resolution (dependencySnapshotBefore) and a fresh re-collection after build hashing. Symmetric to error 96 but for the dependency tree (node_modules, manifests, vendored grammars): if dependencyInputs differ across the two passes, the dependency identity is not stable and the resolution aborts.","triggerScenarios":"dependencySnapshot(collectDependencyInputs(...)) is computed twice; isDeepStrictEqual compares the two. Any change in resolved packages, edges, manifest bytes, lockfile bytes, vendored manifests, or directory/path guards between the two passes triggers the throw, naming packageRoot. Typically an install/add/remove happening during identity resolution.","commonSituations":"A package manager running in parallel (`npm install`, `pnpm add`, `yarn`) mutating node_modules; an IDE auto-installing a missing import; a postinstall script still writing vendored grammars; a CI that starts the analyzer before the install step finished; a docker layer that defers node_modules materialization.","solutions":["Finish all installs before resolving identity: run `npm install` (or equivalent) to completion, then start the analyzer.","Hold the analyzer until package managers are idle (no running npm/pnpm/yarn processes).","In CI, sequence the analyzer strictly after the install step and before any watch/dev step.","If a postinstall writes to vendor/, ensure it has exited before the analyzer starts."],"exampleFix":"// before: CI starts analyzer while `pnpm install` still writing node_modules\n//   -> \"Analyzer dependency runtime changed while its identity was being computed: /repo\"\n//\n// after: serialize install -> analyze\n//   $ pnpm install --frozen-lockfile\n//   $ node .gitnexus/run.cjs analyze --index-only","handlingStrategy":"retry","validationCode":"function assertNoRunningInstaller() {\n  // Refuse to resolve identity while a package manager may be mutating node_modules.\n  const { execSync } = require('node:child_process');\n  try {\n    const out = execSync('pgrep -fl \"npm install|pnpm install|yarn install\"', { stdio: ['ignore','pipe','ignore'] }).toString();\n    if (out.trim()) throw new Error(`Package manager still running:\\n${out}`);\n  } catch (e) {\n    if (e.message.startsWith('Package manager')) throw e;\n    // pgrep found nothing (exit 1) -> ok\n  }\n}\n// assertNoRunningInstaller();","typeGuard":null,"tryCatchPattern":"try {\n  identity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);\n} catch (err) {\n  if (err.message.startsWith('Analyzer dependency runtime changed while its identity was being computed:')) {\n    // install was still flushing; one retry after quiescence is reasonable.\n    identity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);\n  } else throw err;\n}","preventionTips":["Sequence install -> analyze strictly; never overlap them.","Use `npm ci` / `pnpm install --frozen-lockfile` for deterministic, completed installs before analysis.","Ensure postinstall scripts (which write to vendor/) have exited before invoking the analyzer.","Disable IDE auto-install-on-save during analyzer runs."],"tags":["analyzer-identity","toctou","concurrency","dependency-graph"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}