Skip to content

Add a way to exclude file or directory watching #36035

Closed
@slanden

Description

@slanden

Template info added by @mjbvz

TypeScript Version: 3.7.3

Search terms:

  • watcher
  • linux
  • tsserver

  • VSCode Version: 1.41.1 AND 1.42.0-insider
  • OS Version: Linux x64 5.0.0-37-generic (Ubuntu 18.04.3 LTS)

Steps to Reproduce:

  1. Clone the following test repo with only one npm dependency in it: https://github.com/slanden/vscode-watcher-test.git
  2. Run npm i
  3. Download this GitHub user's script that shows the currently registered watchers
  4. Open the empty project in VS Code
  5. Run the script to see that there should not be any VS Code file paths taking more than ~80 or so watchers
  6. In VS Code, add a subdirectory (beside node_modules) and in it put an index.js file
    • I tried a file without a file extension and it did not cause issues.
  7. Run the script again to see that two VS Code file paths now take ~2,600+ watchers

The script results show these two two Code paths if using regular VS Code:

INOTIFY WATCHER COUNT PID CMD
2836 29232 /usr/share/code/code --max-old-space-size=3072 /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsse
2642 29250 /usr/share/code/code /usr/share/code/resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTy

OR for VS Code Insiders, the files would be:

INOTIFY WATCHER COUNT PID CMD
2836 31167 /usr/share/code-insiders/code-insiders --max-old-space-size=3072 /usr/share/code-insiders/resources/app/extensions/node_
2642 31184 /usr/share/code-insiders/code-insiders /usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/typ

Does this issue occur when all extensions are disabled?: Yes

What is expected?

node_modules/ should be excluded from being watched, whether by the VS Code default Watcher Exclude patterns or by setting them explicitly in settings.json.

My Settings

My VS Code Watcher Exclude settings have the following ignore patterns by default.

**/.git/objects/**
**/.git/subtree-cache/**
**/node_modules/**

Adding them explicitly to settings.json with

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true
  }

ultimately doesn't work. I say "ultimately" because I noticed when I first added it, the two VS Code watcher paths and their watchers were removed for that session. But, upon restarting VS Code they were back and I was hitting the "watcher limit reached" error again.

I have found other GitHub issues that were similar, but not the same. Issue microsoft/vscode#59679 is the closest to what I'm experiencing but it was closed as a duplicate to microsoft/vscode#40898. This is not a duplicate issue to microsoft/vscode#40898 as this is for a single-root workspace.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions