Skip to content

Troubleshooting Linux Electron Debug Crash (ENOSPC: System limit for number of file watchers reached) ​

1. Symptoms and Root Cause Analysis (RCA) ​

When running the SyncETA Electron application in debug mode (yarn dev:debug) in a Linux desktop development environment, the Vite/Chokidar file watcher monitors file descriptors inside node_modules and workspace subdirectories. This exceeds the Linux kernel's default inotify watcher limit (8192 or 65536), causing the process to terminate abnormally with an ENOSPC: System limit for number of file watchers reached exception.


2.1 Check Current Kernel Values ​

bash
cat /proc/sys/fs/inotify/max_user_watches
cat /proc/sys/fs/inotify/max_user_instances

2.2 Apply Immediately at Runtime (Temporary) ​

bash
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl fs.inotify.max_user_instances=1024

2.3 Apply Permanently (/etc/sysctl.d/99-inotify.conf) ​

Register a sysctl.d configuration file so that the settings persist across system reboots.

bash
echo 'fs.inotify.max_user_watches=524288' | sudo tee /etc/sysctl.d/99-inotify.conf
echo 'fs.inotify.max_user_instances=1024' | sudo tee -a /etc/sysctl.d/99-inotify.conf
sudo sysctl -p /etc/sysctl.d/99-inotify.conf

After applying the configuration, re-run yarn dev:debug to verify normal startup.


3. Solution 2: Switch to Polling Mode When Kernel Parameters Cannot Be Modified (Containers / Restricted Environments) ​

In CI container environments without sudo privileges or where modifying kernel parameters is restricted, enable polling mode instead of relying on filesystem events.

3.1 One-Time Environment Variable Execution ​

bash
CHOKIDAR_USEPOLLING=1 CHOKIDAR_INTERVAL=800 yarn dev:debug

3.2 Register in IDE Run/Debug Configuration ​

You can apply these settings permanently in IntelliJ IDEA by adding the following variables under Run/Debug Configurations -> Environment variables:

Environment Variable KeyRecommended ValueDescription
CHOKIDAR_USEPOLLING1Enables periodic file state polling instead of OS kernel inotify
CHOKIDAR_INTERVAL800File change detection polling interval (in ms, minimizing CPU overhead)