Skip to content

fix(core): mark all projects affected when a global package is not in the graph - #36485

Open
gaurav0107 wants to merge 1 commit into
nrwl:masterfrom
gaurav0107:fix/36415-gettouchednpmpackages-global-package-fal
Open

gaurav0107 wants to merge 1 commit into
nrwl:masterfrom
gaurav0107:fix/36415-gettouchednpmpackages-global-package-fal

Conversation

@gaurav0107

Copy link
Copy Markdown
Contributor

Current Behavior

getTouchedNpmPackages only consults globalPackages after resolving the changed dependency to a node in the project graph. When neither projectGraph.externalNodes nor projectGraph.nodes has a match, it records the name in missingTouchedNpmPackages and continues — so the check that returns every project is unreachable for a global package that has no node:

if (!npmPackage) {
  missingTouchedNpmPackages.push(c.path[1]);
  continue;                       // <- bails
}
...
if ('packageName' in npmPackage.data) {
  if (globalPackages.has(npmPackage.data.packageName)) {
    return Object.keys(projectGraph.nodes);   // <- never reached for those
  }
}

getGlobalPackages unconditionally appends 'nx', so bumping nx's own version in package.json is the common way to hit this: the run logs The affected projects might have not been identified properly. The package(s) nx were not found. and marks nothing affected, instead of invalidating the whole workspace.

Expected Behavior

A change to a global package (an nx.json plugin package, or nx itself) marks every project affected regardless of whether that package happens to have a node in the graph, and does not emit the "not found" warning for it. Packages that are genuinely unknown still warn exactly as before.

The fix consults globalPackages with the changed key before falling through to the warning. This also makes the dependencies/devDependencies branch consistent with the overrides/resolutions/pnpm.overrides branch in the same function, which already treats an unresolvable package as "affects everything".

Verification

Full disclosure on what was and wasn't verified locally: this machine cannot host an nx install (the pnpm install does not fit in the available disk), so nx run-many -t test -p nx and nx affected -t lint could not be run — CI is the first place the real jest suite executes. To avoid shipping unverified code, the two changed files were checked directly:

  • Type-checktsc --noEmit (TS 5.9, tsconfig.base.json settings) over both changed files: zero errors in them, and a before/after diff of the full error output is byte-identical, so the change introduces no new type errors.
  • Behavior — the real getTouchedNpmPackages was compiled to CJS and executed against the exact inputs and expectations of the two new tests. Both fail on master (they return []) and pass with this change; the two pre-existing tests covering "unknown package still warns" and "resolvable package returns just that package" pass in both.
  • Formattingprettier --check clean with the repo's .prettierrc options.
  • PR titlenode ./scripts/validate-pr-title.js exits 0.

Related Issue(s)

Fixes #36415

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 96cc69a

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 96cc69a

… the graph

`getTouchedNpmPackages` only consults `globalPackages` after resolving the
changed dependency to a node in the project graph. When the lookup misses, it
records the name in `missingTouchedNpmPackages` and continues, so the check that
returns every project is unreachable for a global package with no node.

`nx` is always a global package and is frequently absent from the graph, so
bumping its own version logged "The package(s) nx were not found" and marked
nothing affected instead of invalidating the workspace.

Consult `globalPackages` with the changed key before falling through to the
warning. The sibling `overrides` branch already treats an unresolvable package
as "affects everything"; this makes the dependencies branch consistent with it.
Genuinely unknown packages still warn as before.
@gaurav0107
gaurav0107 force-pushed the fix/36415-gettouchednpmpackages-global-package-fal branch from eb4920a to 96cc69a Compare July 27, 2026 22:25
@gaurav0107
gaurav0107 marked this pull request as ready for review July 27, 2026 22:25
@gaurav0107
gaurav0107 requested a review from a team as a code owner July 27, 2026 22:25
@gaurav0107
gaurav0107 requested a review from MaxKless July 27, 2026 22:25
@AgentEnder AgentEnder added scope: core core nx functionality type: bug labels Sep 20, 2026
@AgentEnder

Copy link
Copy Markdown
Member

Thanks for the PR, and sorry it sat this long. It needs a push from you to move, because its CI runs have gone stale in a way that cannot be restarted from our side. Rebasing on master and pushing creates a fresh run.

Triage notes (automated triage, reviewed before posting)

Every GitHub Actions workflow on this head commit reports a failed suite with zero check runs, and the run records carry zero jobs. That holds for PR Title Validation and Unmergeable Labels Check as well as CI, which is how you can tell it apart from a real build failure. Nothing in the branch was ever executed, so there is nothing to fix from the logs and no run left to approve. A rebase and push creates a fresh run.

Closes #36415. Branch merges cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: core core nx functionality type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getTouchedNpmPackages never reaches the globalPackages fallback for nx's own version change

3 participants