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(optimizer): ignore EACCES errors while scanner (fixes #8916) #9509

Merged

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 3, 2022

Description

#8916 happens with 2.9.x. But it works with 3.x.x (the error message is present though). I think changes around the scanner affected this.

About Vite 3, the error is thrown from discoverProjectDependencies and catched here. So I assume the optimizer won't run and the deps will be stuck instead of all js files?

// Ensure server listen is called before the scanner
setTimeout(async () => {
try {
debug(colors.green(`scanning for dependencies...`))
const deps = await discoverProjectDependencies(config)
debug(
colors.green(
Object.keys(deps).length > 0
? `dependencies found by scanner: ${depsLogString(
Object.keys(deps)
)}`
: `no dependencies found by scanner`
)
)
// Add these dependencies to the discovered list, as these are currently
// used by the preAliasPlugin to support aliased and optimized deps.
// This is also used by the CJS externalization heuristics in legacy mode
for (const id of Object.keys(deps)) {
if (!metadata.discovered[id]) {
addMissingDep(id, deps[id])
}
}
if (!isBuild) {
const knownDeps = prepareKnownDeps()
// For dev, we run the scanner and the first optimization
// run on the background, but we wait until crawling has ended
// to decide if we send this result to the browser or we need to
// do another optimize step
postScanOptimizationResult = runOptimizeDeps(config, knownDeps)
}
} catch (e) {
logger.error(e.message)
} finally {

This PR fixes the error.

fixes #8916

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.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Aug 3, 2022
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a way around this, even if this means potentially hiding some useful errors. It could be interesting in the future to see if we could only suppress EACCESS errors and not other types but this should be a feature of fast-glob IIUC

@patak-dev patak-dev merged commit 4e6a77f into vitejs:main Aug 10, 2022
@sapphi-red sapphi-red deleted the fix-optimizer-ignore-eaccess-errors branch August 11, 2022 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Main fails to load if a unreadable directory is present
2 participants