Skip to content

flue dev crashes with EMFILE when system hits file watcher limits #314

@astrobot-houston

Description

@astrobot-houston

Originally reported by @kalepail in #313.

All community-submitted pull requests are automatically converted to issues (bugs) & discussions (feature requests, enhancements) where they can be triaged and prioritized. Once prioritized, a PR implementation is created automatically.

Describe the Bug

Running flue dev in a large repository or on a system with file watcher pressure causes the process to crash before the local dev server starts. The crash occurs because fs.watch(projectRoot) throws EMFILE: too many open files, watch (or ENOSPC) when the system's file watcher limit is exhausted, and the error is unhandled.

This is unnecessary because Flue already has the exact list of resolved config files it needs to watch and could poll them individually instead of watching the entire parent directory.

Expected Behavior

flue dev should start the local server even when the system cannot watch the config directory due to resource exhaustion (EMFILE/ENOSPC). Config file change detection should fall back to polling the resolved config files individually, and non-resource watcher errors should continue to fail fast.

Steps to Reproduce

  1. Open a large repository (or a system under file watcher pressure where the OS watcher limit is nearly exhausted)
  2. Run flue dev
  3. Observe that the process exits with EMFILE: too many open files, watch before the dev server starts

Original implementation from #313 by @kalepail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions