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

Every file on PC is watched with dev server when using inline CSS on html page whose path is / #7615

Closed
7 tasks done
Alduino opened this issue Apr 5, 2022 · 3 comments
Closed
7 tasks done

Comments

@Alduino
Copy link

Alduino commented Apr 5, 2022

Describe the bug

I came across this issue from using vite-plugin-ssr, however I think it is an issue with Vite itself so I've put the issue here.

I've spent a little while looking around the code to try to see what the issue is:

It seems to be triggered by the changes in #7262 - this change makes inline CSS become a script pointed at [path]?html-proxy&..., which usually would get resolved to the full path to that HTML file (e.g. /index.html?html-proxy&... -> /home/alduino/.../index.html?html-proxy&...), but when the path is /, it doesn't get resolved to anything (it stays as a URL path) (see ensureEntryFromUrl), so the watcher that is added here will recursively go down every directory and watch it. In my case (and how I found out about the issue), it causes the build to hang for a few seconds and then crash because it tried to resolve /run/udev/watch/1 which is a broken symlink.

This seems to happen with other paths that exist as root directories too - testing with /home makes the build very slow, and with /run Vite crashes with the symlink error. It also crashes if I create an invalid symlink at /run.html/test and then try to load a route at /run.html (So it seems Vite's file resolution is based on if it actually exists or not, as the run.html route wasn't from a real file)

Interstingly, at /, I get the error Failed to resolve entry for package /path/to/vite-reprod-eloop if main is not set (or if it is incorrect) in the package.json (and then if I set it, it crashes with the symlink error), but at /run it just crashes even if main is not set. I've also just tried pointing the main at an empty Javascript file and this issue doesn't happen at all, which is weird.

Reproduction

https://github.com/Alduino/vite-reprod-eloop

System Info

System:
    OS: Linux 5.16 Fedora Linux 35 (Workstation Edition)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 17.08 GB / 31.29 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.volta/tools/image/node/16.14.0/bin/node
    npm: 8.3.1 - ~/.volta/tools/image/node/16.14.0/bin/npm
  Browsers:
    Chromium: 100.0.4896.60
    Waterfox: G4.0.8
  npmPackages:
    @vitejs/plugin-react: ^1.2.0 => 1.3.0 
    vite: 2.9.1 => 2.9.1

Used Package Manager

pnpm

Logs

No response

Validations

@poyoho
Copy link
Member

poyoho commented Apr 22, 2022

I think it same with vitejs/vite-plugin-vue#25 ?

@sapphi-red
Copy link
Member

This might be caused by rollup/rollup#5013

@sapphi-red
Copy link
Member

This should be fixed in Vite 5.0.0-beta.10 as that ensureWatchedFile is now removed.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants