nx: NX Cloud seems to be incorrectly restoring from cache
Current Behavior
We are seeing nx and nx cloud restoring from cache incorrectly during nx build.
Expected Behavior
What should be triggering a new build is restoring from cache and new changes are not being included. This seems to be a regression in new versions of nx and nx cloud (I haven’t been able to pin point when this was introduced).
Steps to Reproduce
The git commits to pass to nx are determined by the environment variable $COMMIT_SHA which is an environment variable for the current commit being built (google cloud build).
# write the git revisions for the nx affected git comparison
echo $COMMIT_SHA > HEAD
echo $(git rev-parse $COMMIT_SHA~1) > BASE
Note, that we have had several reports of team members encountering this same issue (with different commits of course).
The change that I build this morning was a simple one line change. This is a git hub diff of the same commits that were used for the nx build.

npx nx affected:build --base=2d21bb4f635c7c7cda098996416a5ad838629a1f --head=6449eccf47322168812232b5a5e2547ca40636e1 --with-deps --prod --parallel
NX restored from cache incorrectly, as the above changes were not included in the cache restore:

Environment
Node : 14.18.3
OS : darwin x64
npm : 6.14.15
nx : undefined
@nrwl/angular : 13.7.1
@nrwl/cli : 13.7.1
@nrwl/cypress : 13.7.1
@nrwl/detox : undefined
@nrwl/devkit : 13.7.1
@nrwl/eslint-plugin-nx : 13.7.1
@nrwl/express : undefined
@nrwl/jest : 13.7.1
@nrwl/js : undefined
@nrwl/linter : 13.7.1
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : 13.1.2
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : 8.12.11
@nrwl/storybook : 13.7.1
@nrwl/tao : 13.7.1
@nrwl/web : undefined
@nrwl/workspace : 13.7.1
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
@angular-devkit/architect: 0.1302.0
@angular/animations: 13.2.0
@angular/cdk: 13.2.0
@angular/common: 13.2.0
@angular/compiler: 13.2.0
@angular/core: 13.2.0
@angular/elements: 13.2.0
@angular/fire: 6.1.4
@angular/forms: 13.2.0
@angular/localize: 13.2.0
@angular/material: 13.2.0
@angular/material-moment-adapter: 13.2.0
@angular/platform-browser: 13.2.0
@angular/platform-browser-dynamic: 13.2.0
@angular/router: 13.2.0
@angular/service-worker: 13.2.0
@ngrx/effects: 13.0.1
@ngrx/store: 13.0.1
@ngrx/store-devtools: 13.0.1
angular-calendar: 0.28.26
ngx-bootstrap: 6.2.0
@angular-builders/custom-webpack: 13.0.0
@angular-devkit/build-angular: 13.2.0
@angular/cli: 13.2.0
@angular/compiler-cli: 13.2.0
@angular/language-service: 13.2.0
@ngneat/spectator: 6.1.3
@testing-library/angular: 10.11.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 18
Commits related to this issue
- chore: disable nx cloud cache on build https://github.com/nrwl/nx/issues/8828 — committed to mstable/frontend by toniocodo 2 years ago
- feat: add allocations, refactor vaults and structure (#193) * feat: add allocations, refactor vaults and structure * chore: nx caching defaults * fix: add address param, default stale time *... — committed to mstable/frontend by toniocodo 2 years ago
Experiencing the same problem. It mis-computing the hash returning nx cloud results for the wrong build / SHA.
How do we re-open?
@FrozenPandaz apologies for the delayed response (vacation).
This is incredibly hard to reproduce as its inconsistent and only seen within our ci environment. I feel that something within 13.7.0 or 13.7.1 changed how a cache hit is determined and as a result nx incorrectly returns a cached build when it should be triggering a new build.