False-positive cache busts from over-broad dependency "bleedthrough" #11024
-
SummaryTurborepo’s build graph can sometimes be too permissive for dev-only packages, causing false-positive cache invalidations. With the "basic" example, we can see we have the web app and the @repo/eslint-config package. Given {
// ..
"tasks": [
{
"taskId": "@repo/eslint-config#build",
"task": "build",
"package": "@repo/eslint-config",
"hash": "7f189443198f6183",
"inputs": {
"README.md": "8b42d901b0e8dee2e21313ec0442c50e9fef038a",
"base.js": "09d316efdb6f6db4f6141815e87980a598f6ff54",
"next.js": "4df088ac8ddeca380f3568f74778906a90314d0b",
"package.json": "5f1f5ff4f4cbb204d4907b9768174e2e1c190945",
"react-internal.js": "daeccba24d4f4b95ad293d175b570acd126628a9"
},
/// ...
},
{
"taskId": "@repo/typescript-config#build",
"task": "build",
"package": "@repo/typescript-config",
"hash": "d1a04ccd0868d600",
"inputs": {
"base.json": "5117f2a3d1c5fe54a344a7152acbe366fe63cdda",
"nextjs.json": "e6defa48fce860cf5570f268d4880161a74789c8",
"package.json": "27c0e60436aac79bd14661e016c8c5721c5db6d6",
"react-library.json": "c3a1b26fbb3b6ad5d606836247a8ca3a1be051c6"
},
// ..
}
]
}We can see the build for web app relies on all the build steps of all it's dependencies. Since the build step is configured on the root, in Why it happens: Because build depends on ^build and web lists @repo/eslint-config as a devDependency, Turbo treats @repo/eslint-config#build as an upstream task. With The impact: Non-material edits (docs or lint rule files) invalidate the web build cache, leading to unnecessary rebuilds and misleading cache misses. Repro: My thoughts
ThoughtsI am happy to manage turbo.json files all over the place for now, just mainly opening this up for discussion. Perhaps there are native solutions I'm missing, or members of the community have solved this already. Looking forward to hearing what people say! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I don't really understand what is being asked here. The default behavior of using the hash of a package as a whole is a safe default, and, if you want to tune the behavior, you absolutely can using While I agree it would be great to be able to make Turborepo have fancy |
Beta Was this translation helpful? Give feedback.
I guess my ask is "What is recommended?" 👻
We have a bunch of packages (just to give some concrete examples) like "test-scripts" or "aws-scripts" or "eslint-configs" (like the example mentioned) which are bleeding into our build cache. We see that they don't impact the build directly, yet bleed over.
Then, two thoughts come from it: maybe there is a built in way for turbo to manage this OR is there a recommended way to handle it?
As I understand, you are saying to fine tune it, just handle the inputs yourself, which makes sense 🫡
I can totally imagine that analysing the dep graph in a way of marking exactly which files were used and include them in the build is maybe an impossible task.. …