Skip to content

Conversation

@atscott
Copy link
Contributor

@atscott atscott commented Jan 20, 2026

…angeWatchedFiles`

This implements onDidChangedWatchedFiles in the language server, which allows the client to communicate changes to files rather than having the server create system file/directory watchers.

This option is enabled in the extension via the
angular.server.useClientSideFileWatcher setting. When enabled, the extension registers a FileSystemWatcher for .ts, .html, and package.json files and forwards events to the server. The server completely disables its internal native file watchers (via a new 'ServerHost' implementation that stubs watchFile/watchDirectory).

This is significantly more performant and reliable than native watching for several reasons:

  • Deduplication: VS Code already watches the workspace. Piggybacking on these events prevents the server from duplicating thousands of file watchers.
  • OS Limits: Since the server opens zero watcher handles, it is impossible to hit OS limits (ENOSPC), no matter how large the repo is.
  • Optimization: VS Code's watcher uses highly optimized native implementations (like Parcel Watcher in Rust/C++) which handle recursive directory watching far better than Node.js's 'fs.watch'.
  • Debouncing: The client aggregates extremely frequent file events (e.g., during 'git checkout'), reducing the flood of processing requests to the server.

This option was tested in one very large internal project and observed ~10-50x improvement of initialization times.

fixes #66543

@atscott atscott requested a review from clydin January 20, 2026 20:56
@atscott atscott added the target: minor This PR is targeted for the next minor release label Jan 20, 2026
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Jan 20, 2026
…angeWatchedFiles`

This implements `onDidChangedWatchedFiles` in the language server, which
allows the client to communicate changes to files rather than having the
server create system file/directory watchers.

This option is enabled in the extension via the
`angular.server.useClientSideFileWatcher` setting.
When enabled, the extension registers a FileSystemWatcher for .ts, .html, and package.json files and forwards events to the server. The server completely disables its internal native file watchers (via a new 'ServerHost' implementation that stubs watchFile/watchDirectory).

This is significantly more performant and reliable than native watching for several reasons:
- Deduplication: VS Code already watches the workspace. Piggybacking on these events prevents the server from duplicating thousands of file watchers.
- OS Limits: Since the server opens zero watcher handles, it is impossible to hit OS limits (ENOSPC), no matter how large the repo is.
- Optimization: VS Code's watcher uses highly optimized native implementations (like Parcel Watcher in Rust/C++) which handle recursive directory watching far better than Node.js's 'fs.watch'.
- Debouncing: The client aggregates extremely frequent file events (e.g., during 'git checkout'), reducing the flood of processing requests to the server.

This option was tested in one very large internal project and observed
~10-50x improvement of initialization times.

fixes angular#66543
@atscott atscott force-pushed the clientsidefilewatcher branch from ef91dbe to 682c770 Compare January 20, 2026 20:57
@amishne amishne added the area: language-service Issues related to Angular's VS Code language service label Jan 21, 2026
@ngbot ngbot bot added this to the Backlog milestone Jan 21, 2026
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jan 23, 2026
@atscott atscott merged commit 6fb39d9 into angular:main Jan 23, 2026
22 checks passed
@atscott
Copy link
Contributor Author

atscott commented Jan 23, 2026

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular Language Service VSCode extension stuck initializing

3 participants