Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: new default file watcher #133753

Closed
3 tasks done
bpasero opened this issue Sep 24, 2021 · 3 comments
Closed
3 tasks done

Test: new default file watcher #133753

bpasero opened this issue Sep 24, 2021 · 3 comments

Comments

@bpasero
Copy link
Member

bpasero commented Sep 24, 2021

Refs: #132483

Complexity: 5

Create Issue


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 Console by putting nsfw into the filter
  • monitor the output: you will see every raw file event reported from the nsfw library and a normalised event signalling the event that is actually being sent to VSCode

image

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 install or git operation) - 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.watcherInclude setting 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 --verbose and search for "watcher", the name of the watcher will be printed (chokidar for macOS, Linux and C# for Windows)
@TylerLeonhardt
Copy link
Member

ensure you can force to use our old watcher when configuring files.legacyWatcher. if you run with --verbose and search for "watcher", the name of the watcher will be printed (chokidar for macOS, Linux and C# for Windows)

I only see [File Watcher (node.js)] does that imply chokidar? It does say [File Watcher (nsfw)] before the change.

@TylerLeonhardt
Copy link
Member

ensure you have a folder in your workspace that is a symbolic link to a folder outside the workspace and use the new files.watcherInclude setting to enable it for watching and verify that works

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?

@TylerLeonhardt TylerLeonhardt removed their assignment Sep 29, 2021
@bpasero
Copy link
Member Author

bpasero commented 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?

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?

No, we only allow paths that are inside the workspace:

// Absolute: verify a child of the workspace
if (isAbsolute(includePath)) {
const candidate = URI.file(includePath).with({ scheme: workspace.uri.scheme });
if (isEqualOrParent(candidate, workspace.uri)) {
pathsToWatch.set(candidate, candidate);
}
}
// Relative: join against workspace folder
else {
const candidate = workspace.toResource(includePath);
pathsToWatch.set(candidate, candidate);
}

@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants