Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

Linux systems crash Vite with ENOSPC: System limit for number of file watchers reached when projects contain many files (e.g., large asset directories). The error message provides no guidance on resolution.

Changes

Added troubleshooting section documenting three solutions:

  • Increase system limit: Commands to check and modify fs.inotify.max_user_watches (temporary and persistent)
  • Exclude directories: Using server.watch.ignored to skip monitoring large asset folders
  • Use polling: Fallback with server.watch.usePolling when native file watching isn't viable
export default defineConfig({
  server: {
    watch: {
      ignored: ['**/storage/**', '**/large-asset-folder/**'],
    },
  },
})

Links to server configuration docs and chokidar performance considerations included.

Original prompt

This section details on the original issue you should resolve

<issue_title>Too many files in cwd will crash Vite on Linux</issue_title>
<issue_description>### 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

<agent_instructions>Add a section to troubleshooting docs. mention fs.inotify.max_user_watches and server.watcher.ignore and server.watcher.usePolling</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 13, 2026 05:45
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance error messages for Vite file watcher limit Jan 13, 2026
Copilot AI requested a review from sapphi-red January 13, 2026 05:47
@sapphi-red sapphi-red marked this pull request as ready for review January 13, 2026 06:16
@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

2 participants