-
Couldn't load subscription status.
- Fork 2.6k
fix(core): ensure daemon writes project graph cache to disk consistently #33217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit 6312756
☁️ Nx Cloud last updated this comment at |
d3916c6 to
045b347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would write cache twice I believe? Can you find where we currently write the cache and see if there's any conditions to remove
There was a problem hiding this comment.
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 possible root cause for your failed CI:
The failure is classified as 'environment_state' rather than 'code_change' for the following reasons:
The PR diff shows a code change to packages/nx/src/daemon/server/project-graph-incremental-recomputation.ts that adds logic to write the daemon's current graph to disk to keep the cache in sync. This change is specifically designed to prevent stale/errored cache issues.
However, the failing task e2e-dotnet:e2e-ci--src/dotnet-multi-project.test.ts is completely unrelated to the project graph caching logic modified in the diff. The test failures show:
- A .NET SDK configuration issue with mutex creation:
System.IO.IOException: The system cannot open the device or file specified. : 'NuGet-Migrations' - The error indicates a file system race condition:
mkdir("/tmp/.dotnet/shm/session63", AllUsers_ReadWriteExecute) == -1; errno == EEXIST - All three test failures occur before any test logic executes - they fail during the setup phase when trying to create .NET projects
- The error
spawnSync /bin/sh ENOENTsuggests the shell environment is not properly initialized or available
The modified code in the PR deals with Nx's project graph daemon and in-memory caching, which has no relationship to:
- .NET SDK initialization
- NuGet package manager configuration
- File system mutex operations in
/tmp/.dotnet/shm/ - The e2e test framework's ability to spawn shell processes
The failures are occurring in the .NET plugin's e2e tests during environment initialization, not during any code path that would interact with the project graph caching changes. The timing and nature of the failures (file system race conditions, mutex conflicts, missing shell access) point to environmental issues in the CI system rather than a logical consequence of the code changes made in this PR.
A code change would likely not resolve this issue, so no action was taken.
🎓 To learn more about Self Healing CI, please visit nx.dev
2d6c7d1 to
6b3cc9a
Compare
|
|
||
| return result; | ||
| } catch (e) { | ||
| if (e instanceof DaemonProjectGraphError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is ever possible.. is it? I'd remove this. writing to the cache above already handles the cases we're seeing I htink.
When the daemon returns a cached project graph from memory, it now always writes it to disk. This prevents cache/daemon mismatches where a non-daemon process writes a stale or errored cache that never gets overwritten by the daemon's valid in-memory graph. Fixes NXC-3030 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
6b3cc9a to
6312756
Compare
…tly (#33217) ## Current Behavior When the Nx daemon returns a cached project graph from memory (without recomputing), it does not write the graph to disk. This creates a cache/daemon mismatch scenario: 1. Daemon has valid project graph in memory 2. A non-daemon process (fallback when daemon fails) encounters errors and writes cache to disk with those errors 3. Parent process gets clean graph from daemon 4. Forked executor processes read from disk cache which contains errors 5. The errors cause `readProjectGraphCache()` to return `null` (when no `minimumComputedAt` is provided) 6. This triggers a misleading "No cached ProjectGraph is available" error instead of surfacing the actual errors This issue manifests intermittently in CI environments, especially when: - Daemon connection timeouts occur - Multiple concurrent processes are running (DTE scenarios) - File system latency is high ## Expected Behavior The daemon should always write its current project graph to disk whenever it returns it, ensuring the disk cache stays synchronized with the daemon's in-memory cache. This prevents stale or errored caches from persisting when the daemon has a valid graph. ## Related Issue(s) Fixes NXC-3030 ## Implementation Details Modified `getCachedSerializedProjectGraphPromise()` in `packages/nx/src/daemon/server/project-graph-incremental-recomputation.ts` to write the project graph cache to disk after retrieving the result, even when reusing the in-memory cached graph. The fix ensures that: - Any errored cache written by a non-daemon process gets overwritten by the daemon's valid graph - Forked executor processes always read a consistent cache that matches what the daemon served to the parent process - Real errors are properly surfaced instead of being hidden by a generic "no cache available" message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]> (cherry picked from commit 7021056)
…tly (#33217) ## Current Behavior When the Nx daemon returns a cached project graph from memory (without recomputing), it does not write the graph to disk. This creates a cache/daemon mismatch scenario: 1. Daemon has valid project graph in memory 2. A non-daemon process (fallback when daemon fails) encounters errors and writes cache to disk with those errors 3. Parent process gets clean graph from daemon 4. Forked executor processes read from disk cache which contains errors 5. The errors cause `readProjectGraphCache()` to return `null` (when no `minimumComputedAt` is provided) 6. This triggers a misleading "No cached ProjectGraph is available" error instead of surfacing the actual errors This issue manifests intermittently in CI environments, especially when: - Daemon connection timeouts occur - Multiple concurrent processes are running (DTE scenarios) - File system latency is high ## Expected Behavior The daemon should always write its current project graph to disk whenever it returns it, ensuring the disk cache stays synchronized with the daemon's in-memory cache. This prevents stale or errored caches from persisting when the daemon has a valid graph. ## Related Issue(s) Fixes NXC-3030 ## Implementation Details Modified `getCachedSerializedProjectGraphPromise()` in `packages/nx/src/daemon/server/project-graph-incremental-recomputation.ts` to write the project graph cache to disk after retrieving the result, even when reusing the in-memory cached graph. The fix ensures that: - Any errored cache written by a non-daemon process gets overwritten by the daemon's valid graph - Forked executor processes always read a consistent cache that matches what the daemon served to the parent process - Real errors are properly surfaced instead of being hidden by a generic "no cache available" message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]> (cherry picked from commit 7021056)
Current Behavior
When the Nx daemon returns a cached project graph from memory (without recomputing), it does not write the graph to disk. This creates a cache/daemon mismatch scenario:
readProjectGraphCache()to returnnull(when nominimumComputedAtis provided)This issue manifests intermittently in CI environments, especially when:
Expected Behavior
The daemon should always write its current project graph to disk whenever it returns it, ensuring the disk cache stays synchronized with the daemon's in-memory cache. This prevents stale or errored caches from persisting when the daemon has a valid graph.
Related Issue(s)
Fixes NXC-3030
Implementation Details
Modified
getCachedSerializedProjectGraphPromise()inpackages/nx/src/daemon/server/project-graph-incremental-recomputation.tsto write the project graph cache to disk after retrieving the result, even when reusing the in-memory cached graph.The fix ensures that:
🤖 Generated with Claude Code