-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
limit dev watcher to avoid overhead from third party processes writing to root #8341
Comments
Additional examples of directories never needed to be watched: |
Thinking about it more, I think the alternative would be the way forward though. There could be usecases where files should be watched but isn't covered in
I'm not sure how |
This seems very related to #7363 as well. I think all the source files should be in a single directory we can watch and all the static files should be in a single directory. Just mixing everything together under root becomes difficult to handle in several scenarios where it turns into a bit of a mess |
This fixes the issue described here: #547 (comment) It does so by configuring `direnv` to write its cache for this project in `~/.cache/direnv/layouts`. This is a bit intrusive, but without this workaround, `vite` commands search the local `.direnv` cache for dependencies, and it adds about 10 seconds or more to every `vite` command. Note that the fix comes from here: https://github.com/direnv/direnv/wiki/Customizing-cache-location Before falling back to this workaround, I also tried the following Vite configuration tricks, but none of them worked: https://vitejs.dev/config/server-options.html#server-watch https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude There are multiple (somewhat) related issues currently filed on Vite which suggest that convincing Vite not to look everywhere in the project root directory is a known issue: https://github.com/vitejs/vite/pull/8778/files vitejs/vite#7363 vitejs/vite#8341
I agree, right now when I create a vanilla project from scratch, even files inside In other words, for me the following helped, but minimally excluding
Edit: But of course, a white-list approach might be even better, if the filtering is simpler that way. Right now the fact that we put files like |
Clear and concise description of the problem
By default,
vite dev
uses a chokidar watcher on root, ignoring only .git and node_modules.https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/index.ts#L291-L302
This causes overhead when processes write files to root that are not needed to be watched. eg. @playwright/test writes to test-results - a lot - if tracing is enabled. (see details below)
Suggested solution
Limit watching to directories matching the fs.allow pattern inside root. This gives frameworks and users more control over what is watched and improves performance.
example code, not perfect but to illustrate whats suggested.
Considerations:
/
in fs.allow?) so keep the root boundary in place.Alternative
manually add ignore entries to known patterns.
This would still incur some cost inside chokidar but at least it would not reach the downstream handlers
Additional context
example of a sveltekit testsuite run with enabled logging inside a watcher demonstrating the current behavior.
https://github.com/sveltejs/kit/runs/6599185996?check_suite_focus=true
Validations
The text was updated successfully, but these errors were encountered: