-
Notifications
You must be signed in to change notification settings - Fork 309
turn off file watchers #1327
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
base: master
Are you sure you want to change the base?
turn off file watchers #1327
Conversation
🦋 Changeset detectedLatest commit: f39c1b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Thanks @evertbouw! Is your project public or do you have a way to reproduce this? I might write an integration test for the compiler if it's something that can be automated. |
@mrm007 Sorry it's proprietary. I'm guessing if you create more files than the system filewachter limit you should run into this, doesn't seems to happen in macos locally but it did on the linux CI/CD box. |
I wonder if perhaps we're creating multiple compilers, instead of re-using the existing one. |
@askoufis that did not fix the problem. devDependencies:
- @vanilla-extract/vite-plugin 4.0.9
+ @vanilla-extract/vite-plugin 0.0.0-fix-watch-mode-20240429115131 (4.0.9 is available)
Done in 14.1s
> vite build
vite v5.2.11 building for production...
transforming...
node:internal/errors:496
ErrorCaptureStackTrace(err);
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/forge/application/vendor/nesbot/carbon/src/Carbon/Lang/dua.php'
at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
at Object.watch (node:fs:2418:34)
at createFsWatchInstance (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44360:17)
at setFsWatchListener (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44407:15)
at NodeFsHandler._watchWithNodeFs (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44562:14)
at NodeFsHandler._handleFile (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44626:23)
at NodeFsHandler._addToNodeFs (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44868:21)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:46061:10)
at NodeFsHandler._addToNodeFs (file:///home/forge/application/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44876:18) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/home/forge/application/vendor/nesbot/carbon/src/Carbon/Lang/dua.php',
filename: '/home/forge/application/vendor/nesbot/carbon/src/Carbon/Lang/dua.php'
} |
The issue can be seen by installing this tool on Linux: https://github.com/mikesart/inotify-info Running Removing the Vanilla Extract Vite Plugin from the configuration means the file watchers do not get created. |
Thanks for sharing this tool, it definitely shows that vanilla-extract/packages/compiler/src/compiler.ts Lines 194 to 196 in 221f07f
However, after looking at a PR in React Router where they turned off their file watcher, maybe we could use the existing vite dev server's file watcher to invalidate the vite node runner's module cache, and then disable the vite node server's watcher. I'll test this out when I get a chance. |
Agree there ought to be a long term fix to add files to the existing vite watcher instead of creating a new vite server. In the short term setting the watch to null only when in vite build mode and setting it in Dec mode should work? |
I thought I was running into this problem laravel/vite-plugin#152 but it was happening in prod builds, so none of the suggestions worked. I traced where the watchers were coming from and it was vanilla-extract. I patched in
watch: null
in my project and now CI/CD builds are working again.