Skip to content

tsgo --watch error: "error starting FSEvents stream" on large node_modules since the fswatch rewrite #4378

Description

@Alex-Bond

Since 7.0.0-dev.20260617.2, tsgo --watch fails to start its file watcher on projects with many watched directories (large/symlinked node_modules).

It prints the compile banner and then:

Starting compilation in watch mode...
failed to watch directory <abs path>/node_modules/.bun/<pkg>: error starting FSEvents stream

and never reaches Found N errors. Watching for file changes.
The one-shot compile (tsgo --noEmit) on the same project succeeds in < 1s, so only watch mode is affected.

I tried to exclude, but the native port seems to ignore watchOptions, so I can't exclude folders.

Steps to reproduce:

macOS 15.7.7 on M1 Max, Bun monorepo. The Bun .bun layout reproduces it immediately because each dependency is its own directory, but any tree large enough to hit the macOS FSEvents stream limit should reproduce.

  1. In a project with a large node_modules (Bun .bun layout works well),
  2. tsgo -p tsconfig.json --watch --noEmit --pretty false
  3. Observe error starting FSEvents stream, no compile cycle.

Best guess on the cause:

Last good 7.0.0-dev.20260616.1 (462a1a4), first bad 7.0.0-dev.20260617.2 (2fb5d4c). The only watcher-related change in that range is #4326 "Rebuilt build mode around fswatch package", building on the fswatch rewrite from #3980 / #4026. The new fswatch appears to fail to open an FSEvents stream once the watched-directory count is large.

Metadata

Metadata

Assignees

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