Is there a way to figure out the list of files Visual Studio Code is watching?

Viewed 671

I have a large codebase opened in Visual Studio Code ( about 60k files ). I get the Unable to watch for file changes ... whenever i do. To get rid of the message, i have the files.watcherExclude setting set up, leaving only about 1000 files on watch. My watcher limit is the typical 8192 files. But with these settings on, the Unable to watch... pops up. I suspect my files.watcherExclude pattern. Is there a way to see the list of files Visual Studio Code is watching ? I can improve my watcherExclude pattern if i can see which files are still being watched.

1 Answers

On Linux, we can use the strace command to find the list of files being watched by a process. So invoking vscode from command line like below:

strace -fe inotify_add_watch  code .

will dump some debug information, specifically pertaining to inotify_add_watch event, which is what is invoked when a new file is added to watch list. (Note that you must exit other instances of vscode before calling the above command from terminal - else it will just bring the other instance into focus and you will not see list of watches being added).

Original information obtained from this blog post: http://hassansin.github.io/Finding-out-Which-Files-Are-Watched-by-Webpack-Using-Strace

Additional Information & Notes

Using strace, I was able to optimize my webpack and vscode watches. (My webpack configuration made it watch files in node_modules folder and vscode was actually watching files in .git folder as well (both should ideally be ignored)). Something like the below works in vscode settings:

"files.watcherExclude": {
        "**/*{.jpg,.png,.gif,.webp,.jpeg}": true,
        "**/.git/**": true,
        "**/node_modules/**": true,
        "**/custom-uploads-folder-path-etc-to-exclude/**" : true

}
Related