Repository navigation
fix(global): prevent concurrent installs from deleting active packages - #3185
Conversation
Protect ownership checks, activation, rollback, and stale installation cleanup with a shared global bin lock so concurrent installs cannot delete the active package. Use the same lock for removal and npm link updates while keeping npm preparation parallel and user prompts outside the lock. Cover concurrent installation, forced replacement, lock contention and process termination, and ownership changes while an npm link prompt is open.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b1aa7fa41
ℹ️ 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".
Remove the global bin lock from split installations, including when it is the only remaining managed artifact. Preserve unrelated files in the shared bin directory and cover both removal paths in the existing regression test.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d724b0f9b
ℹ️ 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".
This reverts commit 7d724b0.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a02eaa57c5
ℹ️ 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".
|
@jong-kyung This fix is so good. How did you discover this issue? |
I'm just comparing how Vite+ and pnpm behave 😄 |
Concurrent global installs can both succeed while the active package is missing. One process can activate an installation, then another process can delete it during cleanup.
For example, two terminals can run
vp install -g typescriptat the same time. Process A lists B's directory for cleanup. Process B then activates that directory and releases its installation lock. Process A can now delete B's directory, although the active metadata still points to it.The shared lock serializes ownership checks, activation, rollback, and cleanup across cooperating Vite+ processes.
Approach
Preparation runs outside the shared lock, as in pnpm's global package activation. Each process holds the lock while it checks ownership, activates the installation, and removes old installations.
Activation after this change
A and B prepare separate installations of the same package. The shared lock makes activation and cleanup run in sequence.
sequenceDiagram participant A as Install process A participant L as Shared lock participant B as Install process B Note over A,B: Both processes prepare their installations in parallel A->>L: A acquires the shared lock Note over A: A activates its installation B->>L: B requests the shared lock Note over B: B waits and retains its installation lock Note over A: A skips B's directory during cleanup Note over A: A releases its installation lock A->>L: A releases the shared lock L-->>B: B acquires the shared lock Note over B: B activates its installation<br/>B removes A's old directory B->>L: B releases the shared lock Note over A,B: B remains active and its files existBoth commands can report success, and
tsccan use the final active installation.References
The following links point to pnpm
v12.11.2at a fixed commit: