`vp config` rewrites unchanged git config on every run, so concurrent runs in linked worktrees fail with "could not lock config file"
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- git, typescript
Hướng nghiên cứu
Bắt đầu trong packages/cli/src/config/hooks.ts, đọc install() và các helper gitConfigSet/gitConfigUnset. Tái hiện bằng các lệnh shell của linked-worktree, sau đó xác minh rằng các giá trị không thay đổi sẽ bỏ qua việc ghi và các lần chạy song song của vp config --no-agent hoàn tất mà không gặp lỗi config-lock, trong khi thiết lập lần đầu vẫn ghi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
install() in packages/cli/src/config/hooks.ts writes git config on every run, even when every value is already what it would write:
git config core.hooksPath <target>, even whencore.hooksPathalready equals<target>git config --local --unset-all vp.hooks.disabled, even when the key is not setgit config --local vp.hooks.dir …/vp.hooks.prefix …, even when the stored values are equal
Linked worktrees share one .git/config, and each write takes git's config.lock. So two vp config runs at the same time, in different worktrees of one clone, collide and one fails:
error: could not lock config file /path/to/repo/.git/config: File exists
When the run comes from a prepare script, the package manager reports a lifecycle failure (ERR_PNPM_EXECUTOR_LIFECYCLE_SCRIPT_FAILED) and the install fails. This happens whenever worktrees are set up in parallel, for example by several coding agents that each create a worktree and install.
Reproduction
No project files needed, only a clone with a second worktree:
mkdir repro && cd repro && git init -q && git commit -q --allow-empty -m init
git worktree add -q ../repro-wt HEAD
vp config --no-agent # first run: sets core.hooksPath once
for i in $(seq 1 20); do
vp config --no-agent >/dev/null 2>&1 || echo FAIL &
(cd ../repro-wt && vp config --no-agent >/dev/null 2>&1 || echo FAIL) &
wait
done | wc -l
On my machine this prints 18. Nothing needs to change after the first run, so the expected result is 0.
Suggested fix
Compare before writing, so a run that changes nothing never takes the lock (this keeps a relative core.hooksPath verbatim too):
function gitConfigSet(key, value) {
+ if (gitConfigGet(key, { local: true }) === value) return { ok: true };
...
}
function gitConfigUnset(key) {
+ if (gitConfigGet(key, { local: true }) == null) return { ok: true };
...
}
// install()
- const { status, stderr } = spawnSync('git', ['config', 'core.hooksPath', location.target]);
+ const { status, stderr } = existingHooksPath === location.target
+ ? { status: 0, stderr: '' }
+ : spawnSync('git', ['config', 'core.hooksPath', location.target]);
With this applied to the 1.0.0 dist as a local patch, 3 parallel runs × 10 rounds gave 0 failures, against 7/10 failures unpatched with 2 in parallel. A first-ever run in a clone still writes, but that happens once per clone rather than once per worktree setup.
System Info
- vite-plus 1.0.0 (global and local)
- git 2.55.0, macOS (Darwin 27)
Used Package Manager
pnpm (12.8.0)
- Ngôn ngữ chính
- Rust
- Star
- 5.8k
- Fork
- 267
- Merge trung bình
- 20 giờ 30 phút
- Pull request đã merge (30 ngày)
- 144
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/vite-plus
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
voidzero-dev/vite-plus#2854 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
voidzero-dev/vite-plus#2801 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
voidzero-dev/vite-plus#2097 · 10 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
voidzero-dev/vite-plus#2850 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/vite-plus#2848 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/vite-plus
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
state:triage-needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Automattic/harper#4503 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
tobi/walgit#84 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày