Describe the bug
During development, after running for a while or after multiple file changes, Node crashes with:
const error = new UVException({
^
Error: EMFILE: too many open files, watch
This appears to be related to chokidar (version 4.0.3) which WXT uses for file watching. The error occurs even though:
- System
ulimit -n is set to 65536
- Actual open file count is very low (~113 files across all vite processes)
This suggests it's not a real file descriptor exhaustion but a bug in chokidar itself, as reported in paulmillr/chokidar#1385
Root Cause Analysis
WXT depends on chokidar 4.0.3 through multiple paths:
- Direct dependency of
wxt
- Via
c12 (wxt's sub-dependency)
- Via
@wxt-dev/i18n
Chokidar 4.x appears to have race condition issues that cause false EMFILE errors even when file descriptors are not actually exhausted.
Note: Vite itself no longer uses chokidar (switched to native fs.watch or @parcel/watcher in Vite 5+), so this issue is specific to WXT's own file watching.
Question for Maintainers
Would it be possible to switch WXT's file watcher away from chokidar to something more stable like @parcel/watcher or native fs.watch? This would align with what Vite itself has done and potentially avoid these reliability issues.
Reproduction
Using Read Frog (open source browser extension):
git clone https://github.com/mengxi-ream/read-frog.git
cd read-frog
pnpm install
pnpm dev
Then make several file edits or wait for a while. The EMFILE error will eventually crash the dev server.
System Info
- WXT: 0.20.13 (latest)
- chokidar: 4.0.3 (via WXT)
- OS: macOS Darwin 25.2.0
- Node: v22.x
- ulimit -n: 65536
Validations
Describe the bug
During development, after running for a while or after multiple file changes, Node crashes with:
This appears to be related to chokidar (version 4.0.3) which WXT uses for file watching. The error occurs even though:
ulimit -nis set to 65536This suggests it's not a real file descriptor exhaustion but a bug in chokidar itself, as reported in paulmillr/chokidar#1385
Root Cause Analysis
WXT depends on chokidar 4.0.3 through multiple paths:
wxtc12(wxt's sub-dependency)@wxt-dev/i18nChokidar 4.x appears to have race condition issues that cause false EMFILE errors even when file descriptors are not actually exhausted.
Note: Vite itself no longer uses chokidar (switched to native
fs.watchor@parcel/watcherin Vite 5+), so this issue is specific to WXT's own file watching.Question for Maintainers
Would it be possible to switch WXT's file watcher away from chokidar to something more stable like
@parcel/watcheror nativefs.watch? This would align with what Vite itself has done and potentially avoid these reliability issues.Reproduction
Using Read Frog (open source browser extension):
git clone https://github.com/mengxi-ream/read-frog.git cd read-frog pnpm install pnpm devThen make several file edits or wait for a while. The EMFILE error will eventually crash the dev server.
System Info
Validations