Skip to content

Too many files in cwd will crash Vite on Linux #21384

@guoyunhe

Description

@guoyunhe

Describe the bug

Linux has a default limit of file watchers (around 10K). If you happen to have 1M images in working directory, Vite server will crash.

Workaround is to add folders to server.watch.ignore. However, the error messages should be more instructive.

Reproduction

https://github.com/guoyunhe/vite-file-watcher-limit

Steps to reproduce

git clone git@github.com:guoyunhe/vite-file-watcher-limit.git
cd vite-file-watcher-limit
pnpm i
pnpm dev

Wait for 10s and it will probably crash

System Info

System:
    OS: Linux 6.18 openSUSE Tumbleweed 20260106
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 19.64 GB / 31.27 GB
    Container: Yes
    Shell: 5.3.9 - /bin/bash
  Binaries:
    Node: 22.21.1 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.9.4 - /usr/bin/npm
    pnpm: 10.20.0 - /home/guo/.local/share/pnpm/pnpm
    Deno: 2.4.5 - /usr/bin/deno
  Browsers:
    Chromium: 143.0.7499.169
    Firefox: 146.0.1
    Firefox Developer Edition: 146.0.1
  npmPackages:
    @vitejs/plugin-react: ^5.1.1 => 5.1.2 
    vite: ^7.2.4 => 7.3.1

Used Package Manager

pnpm

Logs

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/guo/git/vite-file-watcher-limit/storage/file-319871.jpg'

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions