Skip to content
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

Unexpected cache behavior (unexpected hits and unexpected outputs) after renaming file #23106

Open
1 of 4 tasks
ChumpChief opened this issue Apr 30, 2024 · 1 comment
Open
1 of 4 tasks
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@ChumpChief
Copy link

Current Behavior

In the repro repo, the "build" command has caching enabled. Running it (pnpm build at root) does the correct thing in response to modifying file contents, but renaming the file exhibits a couple strange behaviors. The repro steps walk through a series of actions to encounter several unexpected symptoms, annotated with ❌. I believe this is a regression, since I repro on nx 18.3.4 but not 17.0.6.

Expected Behavior

Renaming the file should have similar impact on determining cache hits as modifications to file contents.

GitHub Repo

https://github.com/ChumpChief/nx-repro

Steps to Reproduce

Prereq: pnpm globally installed

  1. Clone the repro repository
  2. pnpm i at repo root
  3. pnpm build at repo root
  4. Observe packages/testPackage/built contains the expected foo.js
  5. mv packages/testPackage/foo.ts packages/testPackage/bar.ts at repo root
  6. pnpm build at repo root
  7. Observe the build command DOES NOT get a cache hit, which is expected since we renamed the file ✅
  8. Observe packages/testPackage/built contains the expected bar.js (and still has foo.js which is expected since we didn't do anything to delete it). ✅
  9. mv packages/testPackage/bar.ts packages/testPackage/woz.ts
  10. pnpm build at repo root
  11. Observe the build command DOES get a cache hit, which is surprising since we renamed the file ❌
  12. Observe packages/testPackage/built is missing the expected woz.js (but still has the foo.js and bar.js files as expected since we didn't do anything to delete them). ❌
  13. pnpm clean at repo root (which will delete the built output)
  14. mv packages/testPackage/woz.ts packages/testPackage/foo.ts (returning the file name back to the original state)
  15. pnpm build at repo root
  16. Observe the build command DOES get a cache hit, which is expected since we built with foo.ts in step 3 ✅
  17. Observe packages/testPackage/built has the expected foo.js, but surprisingly also has bar.js (which was not part of the output from step 3). ❌

Nx Report

Node   : 20.12.2
OS     : darwin-arm64
pnpm   : 9.0.6

nx          : 18.3.4
@nrwl/tao   : 18.3.4
typescript  : 5.4.5

Failure Logs

There are no failure logs, all commands report as passing.

Package Manager Version

9.0.6

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

  • The top tsconfig.json is just the default one created from tsc --init.
  • Does NOT repro on nx 17.0.6 with everything else the same.
    • However, step 15 does not get a cache hit which seems surprising but relatively benign.
    • I did not try to narrow down the first-repro-version further.
@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label May 8, 2024
@rezoled
Copy link

rezoled commented May 22, 2024

Same for me here, I have GQL files that we generate TS file from. the task to generate the files id dependant on **/*.gql files.
Editing or creating new files works great, but when moving or renaming files the cache misses the changes and loads the cached task output.

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

No branches or pull requests

4 participants