fix: EPERM error on Windows when processing dependencies #8235
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.
Description
Fix a rare for people but consistent for me issue that results in an EPERM error when renaming the
.vite/processing
dir to.vite/deps
. See #7939 for a discussion of the issue.This PR adds retries to the remove dst step of the remove dst, rename src->dst process used when processing dependencies.
During testing I observed that as part of loading a page, the dependency processing/optimisation logic in vite can be invoked more than once, this resulted in the following flow
processing
for working filesdeps
processing
todeps
processing
for working filesdeps
processing
todeps
The error mentioned in the issue is triggered at step 4.iii, but during testing I've identified that the underlying problem is actually a race/conflict between steps 2.iii and 4.ii - effectively deleting
deps
can sometimes fail without saying it has failed, it can say the dir is deleted when there are still files, or the dir itself, on the FS.If logging is added to print each time the
removeDir
in this PR errors I see output like the followingFixes #7939
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).