Skip to content

EBADF error when watching tons of files on macos #1385

@bluwy

Description

@bluwy

Describe the bug

When watching many files on macos. spawning a child process causes EBADF errors consistently. (likely due to reaching maximum file descriptors?)

Versions (please complete the following information):

  • Chokidar version: v4
  • Node version: 18, 20
  • OS version: MacOS 15.1

To Reproduce:

https://github.com/bluwy/chokidar-lots-of-files-repro

Steps:

  1. node gen.js (generate files in src/ to watch)
  2. node test.js (watches files and tries to run the ls bash command)

Expected behavior

EBADF errors should not appear when spawning a child process after watching tons of files.

Additional context

With chokidar v4 removing fsevents and using fs.watch, this issue is blocking Vite and Nuxt from upgrading to v4 as there's no easy workaround to the problem (other than usePolling).

Users have also tried adjusting ulimit to extend the maximum file descriptors, but it didn't fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions