Skip to content

fix(core): only defer hashing on dependencies that produce outputs - #36923

Draft
FrozenPandaz wants to merge 3 commits into
masterfrom
fix/defer-hashing-on-output-deps
Draft

fix(core): only defer hashing on dependencies that produce outputs#36923
FrozenPandaz wants to merge 3 commits into
masterfrom
fix/defer-hashing-on-output-deps

Conversation

@FrozenPandaz

Copy link
Copy Markdown
Contributor

Current Behavior

A task with a dependentTasksOutputFiles input is deferred from up-front hashing whenever it has any dependency, and the batch path re-runs it whenever any direct dependency misses the cache. The native hasher already ignores dependencies that declare no outputs, so those deferrals buy nothing: the task's hash cannot change.

Consequences:

  • The task reaches Nx Cloud with no hash, so it can never be classified as a remote cache hit at DTE start and is always distributed and executed.
  • Batch executors never cache-check the task; it runs and is re-hashed afterwards even when the only missed dependency produced nothing.

Example in this repo: e2e-maven:e2e-ci--* depends on nx-maven-plugin:install, which has no outputs and cannot affect the e2e task's hash.

Expected Behavior

Hashing is deferred only when a dependency that actually produces outputs feeds the task's hash.

  • New getDependenciesWithOutputsToHash mirrors the native collect_task_dependencies BFS and returns the ids of dependency tasks with non-empty outputs, walking transitively when any dependentTasksOutputFiles entry is transitive.
  • hashTasksThatDoNotDependOnOutputsOfOtherTasks hashes a task up front when that set is empty.
  • The coordinator loop waits on the output-bearing set (transitive) instead of all direct dependencies.
  • applyBatchCachedResults defers a task only when an output-bearing dependency was a cache miss, bringing the batch and non-batch paths onto one rule.

Tasks whose only relevant dependencies are output-less now get a hash up front, which lets Nx Cloud consider them for a remote cache hit and lets batch executors replay them instead of re-running.

Related Issue(s)

N/A


View Polygraph session ↗

A task with a dependentTasksOutputFiles input was deferred from up-front
hashing whenever it had any dependency, and the batch path re-ran it
whenever any direct dependency missed the cache. The native hasher
already ignores dependencies with no outputs, so those deferrals bought
nothing: the task's hash could not change.

Add getDependenciesWithOutputsToHash, mirroring the native BFS, and gate
all three sites on it. Tasks whose only relevant dependencies are
output-less now get a hash up front, which lets Nx Cloud consider them
for a remote cache hit at DTE start and lets batch executors replay them
instead of re-running.

(cherry picked from commit d986b06498ed5a7439ad3f2097fed8944888abf2)
@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit a98b4b7
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a9b374cfb602e00087a992f
😎 Deploy Preview https://deploy-preview-36923--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit a98b4b7
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a9b374c94bb5b000774213c
😎 Deploy Preview https://deploy-preview-36923--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 54a65b4

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ❌ Failed 11m 59s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 2s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-04 21:42:24 UTC

…okup

check-task-files already walks a task's dependencies with the same
direct-or-transitive switch. Lift it into task-graph-utils and use it
for getDependenciesWithOutputsToHash instead of a second traversal.

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant