Repository navigation
fix(cli): keep git hooks running when vp config rewrites the dispatcher - #3570
Merged
Merged
Conversation
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://triagebot-fix-3567-viteplus-dev.voidzero-docs.workers.dev (commit c73f258)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
The final newline alone does not stop the failure in #3567 when the shell reads the dispatcher in blocks smaller than the file. macOS /bin/dash and BusyBox builds with the default config read 1 KiB at a time, and the dispatcher is larger. Put the dispatcher body in a brace group, so the shell parses the whole file before it runs the hook. Create the temp file with `wx` and set its mode before the rename. Run the hook tests with dash where it exists, and add a test that runs `install()` while a hook runs a dispatcher from vite-plus 1.8.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fengmk2
force-pushed
the
triagebot/fix-3567
branch
from
November 25, 2026 07:26
3733d35 to
d0e211e
Compare
On Windows, a temp file that another process locks can make the rename and the cleanup both fail. The cleanup error then left the write helper, and the in-place fallback did not run. A temp name with the pid can also match a file from a crashed run, which forces the in-place write. Use a random temp name, and make the cleanup best-effort so that the fallback always runs. The tests now check that no temp file stays, and release the waiting hook when an assertion fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`no-promise-executor-return` rejects `new Promise((resolve) => setTimeout(resolve, 20))` because the arrow returns the timer. Use `setTimeout` from `node:timers/promises`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpojer
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a hook runs
vp config(for examplepnpm installwith"prepare": "vp config"inpost-checkout), the hook can fail after the user script completes. The shell reports a syntax error such asUnterminated quoted string, andgit checkoutorgit mergeexits non-zero, although the install succeeded.The hook stub sources
.vite-hooks/_/h. dash and BusyBox ash read a sourced file in blocks and read the next block only when they need it.vp configrewrotehin place, so the shell parsed bytes of the new file after the hook. The last lineexit $chad no final newline, so the shell always read once more at the end of the file.This PR makes two changes:
vp configwriteshand the hook stubs to a temp file in<dir>/_/and renames it over the target. A shell that has the old dispatcher open keeps reading the old file. This also covers the upgrade from a dispatcher that vite-plus 1.8.0 or earlier wrote. If the temp file or the rename fails (for example, when Windows locks the target), the write falls back to an in-place write, as before.{ ... }group, and the generated files end with a newline. The shell parses the whole dispatcher before the hook runs. This protects a running hook when vite-plus 1.8.0 or earlier rewrites the file in place, for example after a checkout of a branch that pins an older version.A final newline alone protects only shells that read the whole dispatcher (1058 bytes) in one block:
/bin/dash, BusyBox with default configThe dispatcher text changes, so the next
vp configorvp hooks enablerun refreshes existing dispatchers one time.Closes #3567
🤖 Generated with Claude Code