fix(core): separate daemon runtime env from graph identity - #36565
Draft
sdjayna wants to merge 2 commits into
Draft
fix(core): separate daemon runtime env from graph identity#36565sdjayna wants to merge 2 commits into
sdjayna wants to merge 2 commits into
Conversation
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
“Berry” is Yarn's name for Yarn 2 and later; this reproduction uses Yarn 4.15.0. When Yarn runs a workspace binary, it does not invoke the binary directly. It creates a fresh temporary
xfs-*directory for that invocation and writes wrappers into it for the selectednode,yarn,node-gyp, and package binaries.Yarn then exposes that runtime directory and puts it first on
PATH:The first
PATHentry is exactly the currentBERRY_BIN_FOLDERvalue. The delimiter is:on macOS/Linux and;on Windows; every remainingPATHentry is the pre-existing toolchain path.The directory is deleted when the Yarn command exits. A new command receives a new random path even when the workspace, lockfile, Node version, Yarn version, and available binaries are unchanged.
Two real consecutive invocations demonstrated the distinction:
After removing that first temporary segment, the complete remaining
PATHwas byte-for-byte identical. Both directories contained the same 73 wrapper names with identical SHA-256 fingerprints. The path changed; the executable environment it represented did not.The Nx client sends its environment snapshot to the persistent daemon. The daemon currently applies the raw values and invalidates the project graph if any non-excluded value differs:
Every
yarn nxcall therefore changes bothBERRY_BIN_FOLDERand the firstPATHsegment. Nx treats those random runtime locations as changes to project-graph identity and rebuilds an unchanged graph. The public reproduction logs this before all three requests on Windows, macOS, and Ubuntu:Expected Behavior
Nx needs two views of the same client environment:
BERRY_BIN_FOLDER, so plugin workers can execute Yarn-provided wrappersFor graph comparison only, Nx should:
BERRY_BIN_FOLDERvalue with a stable Yarn marker.PATHsegment exactly equal to that temporary folder.PATHsegment and SDK/compiler variable.This keeps consecutive Yarn invocations equivalent without collapsing Yarn and direct invocation into the same identity. A direct invocation has no Yarn marker. A real .NET, Java, Node, or compiler path change remains visible and must still invalidate the graph.
The full runtime environment is still applied and forwarded on every request; normalization affects cache-validity comparison only.
Before / After Acceptance
The before values are measured on stock Nx 23.1.1. The after values are acceptance targets, not patched results yet.
PATHinvalidationFor context, when the large-workspace graph was actually reused outside the Yarn-triggered invalidation path, three requests completed in 266-270ms, a 37-62x difference from the repeated 10.030-16.543s path. This is evidence of the available cache-hit path, not a claimed patched result.
No annual productivity saving is claimed without command-frequency and developer-population data.
What This PR Changes
BERRY_BIN_FOLDERvalue with a stable Yarn marker and removes only matching temporaryPATHsegments from graph comparison.PROJECT_CWD,INIT_CWD, all realPATHsegments and SDK variables graph-significant.Testing
Completed locally:
PATHchange remains graph-significant.Required in CI / dedicated PR release:
Risk and Mitigation
This PR does not broadly ignore
PATHand does not remove Berry wrappers from runtime. Only the exact path segment equal toBERRY_BIN_FOLDERis excluded from graph identity. Lockfile and project-file changes continue to invalidate through file watching.Related Issue(s)
Fixes #36564
This change is a candidate for a dedicated PR release so graph output and warm-command latency can be compared in a large Yarn 4 workspace.