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: gracefully handle forbidden filesystem access #10793

Merged
merged 7 commits into from
Nov 13, 2022

Conversation

brillout
Copy link
Contributor

@brillout brillout commented Nov 5, 2022

Description

Prior to this PR, URLs like /root make Vite throw an error.


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.

@patak-dev
Copy link
Member

Note: just a detail, but about the "is self explanatory" in the Description, IMO you could avoid that line and directly add the Additional Context line instead there.

@brillout brillout changed the title fix: handle forbidden filesystem access fix: gracefully handle forbidden filesystem access Nov 8, 2022
@brillout
Copy link
Contributor Author

brillout commented Nov 8, 2022

I added unit tests and rewrote isFileReadable() which was buggy: if you revert the new implementation you'll see the unit test fail.

I also removed comments that weren't useful. (The comments were linking to #2051 which doesn't provide much information.)

The new implementation only uses fs.accessSync() (instead of fs.statSync()) because it's semantically more accurate, which is also important for performance.

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.

Thanks @brillout! This looks good to me now.

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label Nov 8, 2022
@patak-dev patak-dev merged commit 92637a2 into vitejs:main Nov 13, 2022
@brillout brillout deleted the fix/fs-forbidden branch September 18, 2024 08:14
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.

3 participants