Repository navigation
Closed
Labels
Milestone
Description
Refs: #132483
- macOS TylerLeonhardt
- linux Logan Ramos (@lramos15)
- windows João Moreno (@joaomoreno)
Complexity: 5
The file watcher (vscode-nsfw) that was previously only used in multi-root workspaces is now enabled by default on all platforms even when opening a single folder. On top of that, the watcher service that leveraged it in VSCode was rewritten.
Setup: best to test this on a larger code base (like VSCode itself) and doing changes not only in root but also in deep hierarchies. In order to diagnose issues you can:
- run
code-insiders --verbose - filter the
Consoleby puttingnsfwinto the filter - monitor the output: you will see every raw file event reported from the
nsfwlibrary and a normalised event signalling the event that is actually being sent to VSCode
IMPORTANT: over the years we have built a lot of measures to workaround missing file events making it actually a bit harder to test the functionality of these events. As such:
- never do a file modification in the same VSCode window that you observe because when e.g. deleting a file using VSCode explorer, we remove it instantly knowing that it was deleted
- even when you do a change outside of the VSCode window, make sure to observe the change in the window without moving focus into the window - we refresh the explorer and opened editors when that happens assuming there was a change
Testing Events
- basic operations are reflected in the VSCode explorer when done from a VSCode explorer in another window
- file/folder create
- file/folder delete
- file/folder move
- file/folder rename
- file/folder copy
- the same is true when doing these operations from the native OS explorer (e.g. Windows explorer, macOS Finder)
- changes to files are reflected in the editor if the file is opened in the editor
Testing Robustness
- even under large pressure the watching never stops working (e.g. large
npm installorgitoperation) - monitor devtools output for information in case it stops working - macOS/Linux: delete the folder that you opened as workspace and bring it back and verify the file watcher continues to work without window reload
- Linux: configure a low
fs.inotify.max_user_watches(instructions), restart and open a large folder with VSCode and verify you see a warning notification telling you how to increase that limit
Testing New Settings
- ensure you have a folder in your workspace that is a symbolic link to a folder outside the workspace and use the new
files.watcherIncludesetting to enable it for watching and verify that works - ensure you can force to use our old watcher when configuring
files.legacyWatcher. if you run with--verboseand search for "watcher", the name of the watcher will be printed (chokidarfor macOS, Linux andC#for Windows)

Activity
TylerLeonhardt commentedon Sep 29, 2021
I only see
[File Watcher (node.js)]does that imply chokidar? It does say[File Watcher (nsfw)]before the change.TylerLeonhardt commentedon Sep 29, 2021
So does this mean I could add a ton of paths to this setting that are not opened in VS Code and nsfw will still watch them regardless? Could I add
/as a path in my workspace settings and slow down the user's machine?bpasero commentedon Sep 30, 2021
TylerLeonhardt you should see
[File Watcher (chokidar)]but I forgot to mention that for the file watcher to be used, you need to open a folder or multi-root workspace and not be in an empty window with loose files. And even when you are in a folder or workspace: any file that is outside of that workspace is watched by a custom node.js based watcher that is only watching that particular file. So maybe that happened here? You can try again by opening a folder and observing files of that folder?No, we only allow paths that are inside the workspace:
vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.ts
Lines 132 to 144 in 24b3b58