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

Inconsistent "cache hit" (regression) on v1.6.0+ #2307

Closed
Joroze opened this issue Oct 23, 2022 · 8 comments · Fixed by #2424
Closed

Inconsistent "cache hit" (regression) on v1.6.0+ #2307

Joroze opened this issue Oct 23, 2022 · 8 comments · Fixed by #2424
Labels
area: caching Issues reported about incorrect cache hits or misses

Comments

@Joroze
Copy link

Joroze commented Oct 23, 2022

What version of Turborepo are you using?

1.6.1

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

Figured I'd just report this bug that is occurring again sooner than later.

#2004 (comment)

TLDR: Sporadic cache misses that I've noticed when using Vite with the React Plugin on NPM.

package.json

...
"vite": "3.1.8",
"@vitejs/plugin-react": "2.1.0",

NPM v8.11.0 (Node v16)
OS/Chip - M2 macOS Monterey v12.6

Expected Behavior

Caching should be 'ol reliable

To Reproduce

Two ways to reproduce:

@Joroze Joroze changed the title Inconsistent "cache hit" (regression) Inconsistent "cache hit" (regression) on 1.6.0+ Oct 23, 2022
@Joroze Joroze changed the title Inconsistent "cache hit" (regression) on 1.6.0+ Inconsistent "cache hit" (regression) on v1.6.0+ Oct 23, 2022
@thenbe
Copy link

thenbe commented Oct 23, 2022

Just thinking out loud here, but Vite generates a temporary file called vite.config.js.timestamp-1663771012345.mjs when building. Not sure if it is generated on every build, but I came to know of its existence after it failed to be deleted a handful of times. This file is often not .gitignored because it is generated in the main project directory (adjacent to vite.config.js)

I wonder if/how this is handled by turbo, and if it could be interfering with the caching fingerprint.

By default (i.e. the inputs key has not been declared in turbo.json), this file should be taken into account in the hashing fingerprint due to (a) it's location and (b) it is not .gitignored. However, this file is only generated during the build command itself and (assuming everything goes smoothly) deleted before the build command exits.

Are there scenarios that could make this file end up in the caching fingerprint? I don't really know anything about turbo's internals besides what's in the docs, so I can't really answer this.

Some discussion on the generated vite file here: vitejs/vite#9470

@nathanhammond
Copy link
Contributor

@Joroze can you try adding the Vite file from the previous comment into your .gitignore file via a glob?

@Joroze
Copy link
Author

Joroze commented Oct 23, 2022

@Joroze can you try adding the Vite file from the previous comment into your .gitignore file via a glob?

@ambiguous48 @nathanhammond

I don't believe this is the culprit. I don't even see that file getting generated.

@thenbe
Copy link

thenbe commented Oct 23, 2022

I don't even see that file getting generated.

The file is deleted immediately after it's creation. You wouldn't see it unless you're looking for it.

If you actually want to see it, run this command, then in another terminal run vite build

for i in {1..240}; do ls -lA | grep "vite"; sleep 0.25; done

I'm not at all saying this is the actual cause of the issue, just replying as to why you're not seeing the file.

@Joroze
Copy link
Author

Joroze commented Oct 23, 2022

I don't even see that file getting generated.

The file is deleted immediately after it's creation. You wouldn't see it unless you're looking for it.

If you actually want to see it, run this command, then in another terminal run vite build

for i in {1..240}; do ls -lA | grep "vite"; sleep 0.25; done

I'm not at all saying this is the actual cause of the issue, just replying as to why you're not seeing the file.

Thanks! Good to know. Anyways, I already tried including something like vite.* and vite.config.js.*/vite.config.ts.* in my root .gitignore and the issue still occurs. Unless I did this wrong?

@weyert
Copy link
Contributor

weyert commented Oct 24, 2022

Are you sure the files get generated in the root? Maybe it needs to be **/vite*

@Joroze
Copy link
Author

Joroze commented Oct 24, 2022

Are you sure the files get generated in the root? Maybe it needs to be **/vite*

Nope, that also does not work.

@AlexAegis
Copy link

Can confirm, rolled back to 1.5.* and caching started working

@mehulkar mehulkar added the area: caching Issues reported about incorrect cache hits or misses label Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: caching Issues reported about incorrect cache hits or misses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants