Inconsistent "cache hit" (regression) on v1.6.0+
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.
https://github.com/vercel/turborepo/issues/2004#issuecomment-1287375565
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:
- Try
npm run buildagainst this kitchen sink example https://github.com/vercel/turborepo/tree/main/examples/kitchen-sink, and you'll notice caching is inconsistent -- (admin workspace specifically because it's already using vite + react plugin) - Try
npm run buildagainst this vite example but add the react plugin to it beforehand https://github.com/vercel/turborepo/tree/main/examples/with-vite, and you'll notice caching is inconsistent
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: https://github.com/vitejs/vite/issues/9470
@Joroze can you try adding the Vite file from the previous comment into your .gitignore file via a glob?
@Joroze can you try adding the Vite file from the previous comment into your
.gitignorefile via a glob?
@ambiguous48 @nathanhammond
I don't believe this is the culprit. I don't even see that file getting generated.
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.
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 buildfor i in {1..240}; do ls -lA | grep "vite"; sleep 0.25; doneI'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?
Are you sure the files get generated in the root? Maybe it needs to be **/vite*
Are you sure the files get generated in the root? Maybe it needs to be
**/vite*
Nope, that also does not work.
Can confirm, rolled back to 1.5.* and caching started working