nrwl / nx

Smart Monorepos ยท Fast CI
https://nx.dev
MIT License
23.69k stars 2.36k forks source link

Cache hits when it shouldn't #28057

Open jlissner opened 1 month ago

jlissner commented 1 month ago

Current Behavior

When editing an input file to a cached task, it only hits the cache on the first re-run of the task. Subsequent re-runs of that task (after subsequent changes) hit the cache when it shouldn't.

Expected Behavior

Anytime a valid input files changes, it shouldn't hit the cache.

GitHub Repo

https://github.com/jlissner/tuskydesign/blob/main/packages/buttons/Button.tsx#L6

Steps to Reproduce

  1. Follow the NPM Workspaces Monorepo tutorial just up until Use Task Pipelines
  2. Edit the Button component in packages/buttons/Button
  3. Build -> Cache Miss (as expected ๐ŸŽ‰)
  4. Edit the Button component again
  5. Build -> Cache Hit ๐Ÿ˜ญ

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.10.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.2.3

nx             : 19.8.0
@nx/js         : 19.7.4
@nx/linter     : 19.7.4
@nx/eslint     : 19.7.4
@nx/workspace  : 19.7.4
@nx/devkit     : 19.7.4
@nrwl/tao      : 19.8.0
@nx/vite       : 19.7.4
@nx/web        : 19.7.4
typescript     : 4.9.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/vite/plugin
---------------------------------------
The following packages should match the installed version of nx
  - @nx/js@19.7.4
  - @nrwl/js@19.7.4
  - @nx/linter@19.7.4
  - @nx/eslint@19.7.4
  - @nx/workspace@19.7.4
  - @nrwl/workspace@19.7.4
  - @nx/devkit@19.7.4
  - @nrwl/devkit@19.7.4
  - @nx/vite@19.7.4
  - @nrwl/vite@19.7.4
  - @nx/web@19.7.4
  - @nrwl/web@19.7.4

To fix this, run `nx migrate nx@19.8.0`

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

jlissner commented 1 month ago

I noticed that whatever file is changed is being removed from the inputs.

Before any changes: Image

After changing Buttons.tsx, then building again Image

xiongemi commented 2 weeks ago

i tried on macos, i could not replicate this issue. maybe a windows issue? let me try to windows.

xiongemi commented 1 week ago

i just tried it on windows. i could not replicate this.

When I change this button file and run nx build @tuskdesign/buttons, it does not hit cache; it rebuilds every time.