-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cache tolerance for old archives #5564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is only enabled for projects using the local cache
This will break use cases where, for example, you use the global cache on the CI and the local cache on your machine.
Locally installs will pass while on the CI it will throw.
I thought about this, and the only solution I could come up with was to introduce a new setting, This setting also allows us to let Yarn reuse files from different compression levels, so it has value in multiple use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks yarn --check-cache
as the new Yarn version with a different cache key can't reproduce the cache entry of the previous Yarn version.
After some discussion I agree enabling this by default is too risky so close from the major release, due to potential issues with setups people may already have (in particular, the story with I turned back the default to |
**What's the problem this PR addresses?** - CRA broke when [we started required that `--cwd` be put before any other argument](#5600 (comment)). CRA is mostly deprecated / unmaintained by now, but it has a decent amount of downloads (more than `create-next-app`), so it doesn't cost us much to special-case a fix for the v4 that we can then drop in v5. - When a machine had a hot cache for package X in both cache versions A and B (each variant having its own checksum), when migrating a project cache version from A to B, Yarn would mistakenly try to validate the variant B using the checksum from variant A. - We already have a mechanism to tolerate checksum changes when going from one cache key to the next, but before #5564 we used to retrieve the cache key from the file name, whereas we now retrieve it from the lockfile instead. A branch of code that relied on the assumption that the cache key could be checked later became invalid, hence the problem. **How did you fix it?** - The `--cwd` flag is now allowed (as a special case) at the end of `yarn add`. - I refactored the "is this locator compatible with the current cache key" function outside of `getLocatorPath`. **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
What's the problem this PR addresses?
Each time we make a change to the libzip or zlib implementation, all generated archives typically see the compression output changed, with no notable changes on the actual content of the files. When the local cache is used this is reflected by git marking all cache files as changed, and requiring to push them anew. This is a very heavy process, especially since the compression prevents git from efficiently diffing the files. The situation is a little better with compression=0 (the new default), but not all projects can use it right away.
How did you fix it?
This diff makes Yarn tolerant to archives generated by older versions, as long as they have been generated by at least the cache version N (called the "checkpoint version"). The checksum is still validated.
This logic isn't enabled by default, by fear of adverse interactions with particular setups (in particular
--check-cache
, which is currently recommended for open-source projects using zero-installs; probably not many, but better to be careful so close from the next major release).Checklist