protibimbok / django-vite-plugin

This plugin configures Vite for use with Django backend.
103 stars 13 forks source link

Error: ENOSPC: System limit for number of file watchers reached #28

Closed asmundur-obrien closed 1 year ago

asmundur-obrien commented 1 year ago

I'm trying to integrate vite in a rather large Django project (somewhere around 28000 files), on a development server that has a rather low system limit (8192) on number of watchers that it allows. But this still happens despite if I set the watch configuration on the vite development server to false like this:

export default defineConfig({ plugins: [ vue(), djangoVite({ input: [ 'src/main.js' ], root: '..' }) ], server: { watch: false } });

which tells me that django_vite_plugin is overwriting that setting of vite. So I'm guessing my approach of getting around that system limit by excluding files I know I won't work, as shown here:

export default defineConfig({ plugins: [ vue(), djangoVite({ input: [ 'src/main.js' ], root: '..' }) ], server: { watch: { excluded: [ '**/node_modules/**', '**/__pycache__/**', '**/*.pyc', '**/*.log', '**/*.sqlite3', '**/migrations/**', '**/.git/**', '**/tests/**', '**/test/**', '**/*.spec.js', '**/test_*.py' ] } } });

is this a bug, or is there a way to tell djangoVite to exclude files from watched files in a similar manner?

I'd rather not mess with the watch limit on the development server, as that setting is above my paygrade.

protibimbok commented 1 year ago

If something works fine in vite but doesn't work when using this plugin then the plugin is the problem. Can you provide me a way to duplicate this environment?

asmundur-obrien commented 1 year ago

my suggestion would be to take a basic django project and put a really low system limit on maximum number of file watches, fewer than the number of files in the django project. I'm working on recreating this scenario in a code project I can share, but it may be a few days until I get to that.

asmundur commented 1 year ago

answering this from my personal account now: I now realized there was a way simpler way to reproduce this.. An easier way to run into the same issue is just finding out your system max file watchers, and create just enough garbage python and or/javascript files that it has to load. And that should recreate this issue. I´d suggest the easiest way would be just to make tons of meaningless database migrations

protibimbok commented 1 year ago

my suggestion would be to take a basic django project and put a really low system limit on maximum number of file watches, fewer than the number of files in the django project. I'm working on recreating this scenario in a code project I can share, but it may be a few days until I get to that.

Please let me know after doing this. You may just write a python script that creates dummy files and then share the limit here.

asmundur commented 1 year ago

my suggestion would be to take a basic django project and put a really low system limit on maximum number of file watches, fewer than the number of files in the django project. I'm working on recreating this scenario in a code project I can share, but it may be a few days until I get to that.

Please let me know after doing this. You may just write a python script that creates dummy files and then share the limit here.

You'll have to do that yourself for your system. You find the limit on linux with cat /proc/sys/fs/inotify/max_user_watches

protibimbok commented 1 year ago

I've tried the following steps:

  1. Change the max_user_watches to a lower value
    sudo sysctl fs.inotify.max_user_watches=20
  2. Create 20+ files
  3. Run npm run dev

I tried this in a WSL (Ubuntu)