Skip to content

instance start crashes on macOS: raw fs.watch watchers have no 'error' listener #405

Backlog

Description

@teddyhwang

On 1f4a9c7 (macOS arm64, Node 26.13.1), every instance start fails with "Instance did not become ready … Error: EMFILE: too many open files, watch … Emitted 'error' event on FSWatcher instance". The preview process held about 376 file descriptors with a soft limit far above that, so it is not the fd limit: libuv's FSEvents stream fails to start, libuv delivers the EMFILE to every watcher on the loop, and the watchers opened by

  • server/watch-roots.ts:19 (watch(ancestor, …))
  • server/extensions.ts:773 (watchRemovals → watchDirectory(directory, …))

have no 'error' listener, so the process dies. Started by hand from the same preview home with a --import preload that only attaches an 'error' listener to each fs.watch, the preview starts and serves.

Suggested fix: attach an 'error' listener to those watchers (log a notice, close, and fall back to the chokidar watcher that already covers the same roots), so one failed FSEvents stream can't kill the server.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions