-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Bugfix 3752 - Artifacts disappearing when missing integrity file #4185
Bugfix 3752 - Artifacts disappearing when missing integrity file #4185
Conversation
Great work @jamsinclair, thanks! Have you checked if it works fine with the |
@@ -34,6 +34,10 @@ export default class PackageInstallScripts { | |||
force: boolean; | |||
artifacts: InstallArtifacts; | |||
|
|||
setForce(force: boolean) { |
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.
Do we really need these setters and getters?
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.
Good question.
The force property was formerly only set on construction of the PackageInstallScripts
class:
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L178
When the install bailout method runs, the PackageInstallScripts
instance has already been created. Adding the setter, allowing overrides, seemed like a simpler solution rather than reinstantiating. Happy to hear another approach.
Edit: Oh, is it all good to override properties directly, this.scripts.force = true
? In that case could definitely remove setter 😂
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.
I think a setter is fine, it's how we already do it (setArtifacts
), and I have the feeling it makes the code a bit safer (because JS doesn't (yet) have private variables, setters are one of the only ways to clearly state that a variable might be updated from the outside).
@arcanis, yup just tested changes now with Looks right. The package install scripts do not seem to take place and reports a warning:
|
Thanks @jamsinclair! A simple solution to an important issue 👌 |
Will this fix be included in 0.27.x and 0.28.x versions soon enough? |
It's already available through the nightly builds. Otherwise, it will be in the next tagged release, which should be the 1.0.0 and should come in the next few weeks. |
Summary
I encountered personally similar problems as described in #3752 after interrupting a yarn install.
After some debugging I isolated this to being that the integrity file is removed during the
linking
step (with good reasons).However, if this file is never rewritten (e.g. user/system interrupted yarn) the next time yarn is invoked it no longer has context of package artifacts, as they are retrieved from the integrity file.
I played around with some solutions and would like to put forward an idea of forcing package installations if the integrity file is missing.
Test plan
I've added two test cases for
add
andinstall
scripts that replicate the reproduction steps listed in #3752 (comment).Without changes to the src code you can see these test cases fail (running Node v8.2.1):
With the src codes changes you can see on CI that all tests pass ✌️
Concerns
I'm not sure but, are there any scenarios where setting
force
in thePackageInstallScripts
would cause the lockfile to be rewritten? Thinking of whether this change would affect flags like--frozen-lockfile
🤔