When attempting to run vp install concurrently in multiple subdirectories, the command frequently fails with an exit code of 1. This is commonly encountered in monorepos or when using build systems like MSBuild that attempt to build multiple frontend projects in parallel.
Steps to Reproduce:
- Create multiple frontend directories (e.g.
frontend-a, frontend-b, frontend-c) initialized with vite-plus.
- On a Windows machine, trigger
vp install inside all of these directories at the exact same time (for example, via parallel MSBuild targets or using a tool like concurrently).
- Observe that one or more of the instances will crash/fail, returning exit code 1.
Expected Behavior:
vp install should be safe to execute concurrently in multiple directories, gracefully handling any internal npm/pnpm cache locking or global store access without crashing.
Current Workaround:
We are currently wrapping vp install and vp build in a global OS-level Mutex during our build process to force sequential execution and avoid the race condition.
Environment:
- OS: Windows
- Package Manager: pnpm (via
vp wrapper)
- Vite Plus version: 0.1.19
Proposed fix
To fix this cross-platform, vite-plus needs to open the lock file without truncating it, using OpenOptions:
use std::fs::OpenOptions;
let lock_path = parent_dir.join(format!("{version}.lock"));
let lock_file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(false) // CRITICAL: Do not truncate, which conflicts with locked files on Windows
.open(lock_path.as_path())?;
lock_file.lock()?;
When attempting to run
vp installconcurrently in multiple subdirectories, the command frequently fails with an exit code of1. This is commonly encountered in monorepos or when using build systems like MSBuild that attempt to build multiple frontend projects in parallel.Steps to Reproduce:
frontend-a,frontend-b,frontend-c) initialized withvite-plus.vp installinside all of these directories at the exact same time (for example, via parallel MSBuild targets or using a tool likeconcurrently).Expected Behavior:
vp installshould be safe to execute concurrently in multiple directories, gracefully handling any internalnpm/pnpmcache locking or global store access without crashing.Current Workaround:
We are currently wrapping
vp installandvp buildin a global OS-level Mutex during our build process to force sequential execution and avoid the race condition.Environment:
vpwrapper)Proposed fix
To fix this cross-platform, vite-plus needs to open the lock file without truncating it, using
OpenOptions: