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

files.watcherExclude doesn't appear to work for paths outside the workspace #223790

Closed
justin39 opened this issue Jul 25, 2024 · 5 comments
Closed
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@justin39
Copy link

justin39 commented Jul 25, 2024

Type: Bug

I have the following entry in my settings (relevant path replaced with foo/bar):

    "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/*/**": true,
        "**/.hg/store/**": true,
        "**/.base_universe/**": true,
        "**/.venv": true,
        "**/.rust_sources": true,
        "**/mount/**": true,
        "**/foo/bar/**": true,
        "/opt/foo/bar": true,
        "/opt/foo/bar/**": true,
    },

But with trace logs on, I still see file watchers added under the /opt/foo/bar/** paths (truncated and munged a bit, but all following paths should match the same /opt/foo/bar/** pattern):

[File Watcher] request stats:

[Summary]
- Recursive Requests:     total: 1491, suspended: 0, polling: 0
- Non-Recursive Requests: total: 0, suspended: 0, polling: 0
- Recursive Watchers:     total: 1491, active: 1491, failed: 0, stopped: 0
- Non-Recursive Watchers: total: 0, active: 0, failed: 0, reusing: 0
- I/O Handles Impact:     total: 1491

[Recursive Requests (1491, suspended: 0, polling: 0)]:
 /home/justinw/path/to/python3.10                                                                                                                                                                       	    (excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /home/justinw/.vscode-server/extensions/ms-python.vscode-pylance-2024.7.1/dist                                                                                                                                	(excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /home/justinw/test-notebook                                                                                                                                                                                   	(excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /opt/foo/bar/path/to/dependency/dist/lib                                         	                                                                                                                            (excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 [...]

[Recursive Watchers (1491, active: 1491, failed: 0, stopped: 0)]:
 /home/justinw/path/to/python3.10                                                                                                                                                                       	    (excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /home/justinw/.vscode-server/extensions/ms-python.vscode-pylance-2024.7.1/dist                                                                                                                                	(excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /home/justinw/test-notebook                                                                                                                                                                                   	(excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 /opt/foo/bar/path/to/dependency/dist/lib                                         	                                                                                                                            (excludes: **/.git/objects/**,**/.git/subtree-cache/**,**/node_modules/*/**,**/.hg/store/**,**/.base_universe/**,**/.venv,**/.rust_sources,**/mount/**,**/foo/bar/**,/opt/foo/bar,/opt/foo/bar/**,/home/justinw/.vscode-server/extensions/**, includes: <all>, filter: <none>, correlationId: <none>)
 [...]

I believe at least one of the last three exclude patterns should have excluded these file watchers. This appears to be creating performance issues, so the easiest workaround would be to exclude these paths; these paths are all stored on read-only storage anyways.

Let me know if this issue should be moved elsewhere - the file watcher requests are almost definitely coming from the Python/Pylance extension. To my understanding though, while the requests are from the extension, the actual file watcher bit gets delegated to VS Code (and to parcel-watcher, as this is with a folder open, hence the recursive watches).

For additional context, this is a Remote SSH instance with Python v2024.10.0 and Pylance v2024.7.1. The only file in the folder, open in the editor, is a Jupyter notebook (although a plain Python script triggers the same behavior). The selected Python interpreter has a very long PYTHONPATH pointing at various places on read-only storage and are the same paths that are VS Code is creating file watches for. Unfortunately, we can't shrink the PYTHONPATH at this time, which is why I wanted to exclude these paths using files.watcherExclude instead.

VS Code version: Code 1.91.1 (f1e16e1, 2024-07-09T22:06:49.809Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 6.1.85-ts1-amd64

@bpasero bpasero added the *as-designed Described behavior is as designed label Jul 26, 2024
@vscodenpa
Copy link

The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines.

Happy Coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
@bpasero
Copy link
Member

bpasero commented Jul 26, 2024

Extensions are able to bypass the setting for file watching when using specific APIs we provide. This is to ensure that the extensions stay functional even in the presence of this setting.

@justin39
Copy link
Author

Extensions are able to bypass the setting for file watching when using specific APIs we provide. This is to ensure that the extensions stay functional even in the presence of this setting.

That's rather surprising behavior - is there any chance that could be made configurable, like some sort of checkbox that forces excludes with a caveat/warning that it may break extensions?

@heejaechang
Copy link

heejaechang commented Aug 1, 2024

@bpasero I think there should be a way to say we want to apply those exclusion, otherwise, every extension needs to know about those settings and have their own mechanism to filter things out.

or at least provide exclude parameter to createFileSystemWatcher api so we can just pass it along.

otherwise, we need to filter it too late which is meaningless since perf cost is already all paid, or we need to somehow figure out how to create new glob pattern by combining include/exclude ourselves.

@bpasero
Copy link
Member

bpasero commented Aug 1, 2024

Yes, we have proposed API for extensions to configure exclude rules, we should be able to finalise that soon, it is already used by TypeScript: #169724

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

4 participants