Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EPERM error on Windows when processing dependencies #8235

Merged
merged 4 commits into from
May 22, 2022
Merged

fix: EPERM error on Windows when processing dependencies #8235

merged 4 commits into from
May 22, 2022

Conversation

mattnathan
Copy link
Contributor

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

  1. Page requests a dependency file
  2. Vite optimises the dependency
    1. uses processing for working files
    2. delete deps
    3. rename processing to deps
  3. Page requests another dependency file
  4. Vite optimises the new dependency
    1. uses processing for working files
    2. delete deps
    3. rename processing to deps

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 following

calling removeDir [...]/node_modules/.vite/deps
retrying removeDir because ENOTEMPTY: ["vuetify.js"]
retrying removeDir because EPERM
retrying removeDir because EPERM
removeDir done in 530ms

Fixes #7939

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
@mattnathan mattnathan requested a review from patak-dev May 19, 2022 15:15
@bluwy bluwy added windows only p2-nice-to-have Not breaking anything but nice to have (priority) labels May 19, 2022
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
@patak-dev patak-dev merged commit 67743a3 into vitejs:main May 22, 2022
@mattnathan mattnathan deleted the fix/eperm-windows branch May 23, 2022 07:13
patak-dev added a commit that referenced this pull request Jun 6, 2022
Co-authored-by: patak-dev <matias.capeletto@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority) windows only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to the run vue app with latest vite version 2.9.0 and above
4 participants