fix(global): introduce install id for global installation#1906
fix(global): introduce install id for global installation#1906liangmiQwQ wants to merge 11 commits into
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc9645b7c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| match PackageMetadata::load(package_name).await { | ||
| Ok(Some(metadata)) if metadata.install_id == current_install_id => {} |
There was a problem hiding this comment.
Re-check active metadata before deleting siblings
When two vp install -g <same package> processes overlap, this check can pass for install A, then install B can save metadata for its own install ID before A reaches the deletion loop. A will still delete every sibling except its own directory, including B's now-active directory, leaving metadata and shims pointing at a removed package tree.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I've thought about only deleing the current using package before, but I am worried about interruption will bring stale packages in this way. Maybe a good balance is to only deleting the current using package there, and handling other rubbish files while upgrading.
There was a problem hiding this comment.
I modified the implementation to only delete original package, and the cleaning work may need doing on another PR.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1311ca417f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The global package reinstall flow introduced by #1698 installs into the final prefix, but it first moves the active prefix to a backup. An interruption can leave the installed package unavailable, and the approaches explored in #1770 and #1773 trade that failure mode for other windows where bins can still break.
This PR adds an install ID to managed package metadata. Each install now writes directly to a sibling prefix such as
packages/<name>#<uuid>, then activates that immutable directory by saving metadata after npm succeeds. The ID is a standard UUID v4 prefixed with#, which is filesystem-safe but invalid in npm package names. Binary dispatch,vp env which,vpx, and global outdated output resolve the active directory from metadata, so no installed prefix is moved.Metadata without
installId, or with an empty value, continues to resolvepackages/<name>for compatibility with existing installations. A successful reinstall deletes only the installation it directly replaced. Cleanup of any older interrupted-install directories throughvp upgradeis intentionally left to a follow-up PR.🤖 Generated with Codex