fix(core): use non-recursive watchers#6911
Conversation
🦋 Changeset detectedLatest commit: 1a81d6d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| scan_kind, | ||
| verbose, | ||
| watch, | ||
| }; |
There was a problem hiding this comment.
We move the watcher instructions into the scanner as much as we can. The scanner knows which folders should be scanned, and thus, which ones should be watched.
| ignore_kind: IgnoreKind::Ancestors, | ||
| })?; | ||
| if is_ignored { | ||
| if self.is_ignored_by_scanner(project_key, scan_kind, &path, IgnoreKind::Ancestors)? { |
There was a problem hiding this comment.
I remove the call to is_path_ignored() here, since it breaks the updates for files that do need watching in project mode. And I added the IgnoreKind argument to is_ignored_by_scanner, because that check was incomplete and could let nested ignored files slip by.
crates/biome_fs/src/fs.rs
Outdated
| } | ||
|
|
||
| if file_type.is_file() { | ||
| scope.spawn(move |_| { |
There was a problem hiding this comment.
Why don't we use spawn anymore? It seems unrelated to the PR
There was a problem hiding this comment.
I just ran into it... it appears completely useless 😅
| pub scan_kind: ScanKind, | ||
| pub verbose: bool, | ||
| pub watch: bool, |
There was a problem hiding this comment.
Can we document the usage of these options?
There was a problem hiding this comment.
Shouldn't we use the function is_dir, which handles symbolic links too?
There was a problem hiding this comment.
Good point, but actually we should exclude symlinks. Fixed.
|
@arendjr did you test the solution against one of the user's reproductions? |
|
Unfortunately we don't have a reproduction for #6838... |
Summary
Fixed #6838: Reduce resource consumption in the Biome Language Server by using non-recursive filesystem watchers instead of recursive ones.
Watchers are responsible for notifying Biome of changes to files in the filesystem. We used to set up a single recursive watcher, but that meant that Biome would receive filesystem notifications for all files in your project, even for ignored folders such as
build/ordist/folders.With this patch, we set up non-recursive watchers only for the folders that are relevant to a project.
Test Plan
Test added. Updated some existing tests.