wxt-dev / wxt-dev/wxt

EMFILE error during development due to chokidar

Open
#2,067 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/paulmillr/chokidar/issues/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

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug.
  • The provided reproduction is a minimal reproducible example of the bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing WXT's own file-watching path and its chokidar 4.0.3 dependency, including the paths through wxt, c12, and @wxt-dev/i18n. Reproduce the crash with the Read Frog commands and repeated edits, then verify that the development server no longer fails with a false EMFILE error after the watcher approach is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.