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

Opening a .js file when node_modules is present causes explosion in number of watchers #49474

Closed
MetRonnie opened this issue Jun 10, 2022 · 8 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@MetRonnie
Copy link

MetRonnie commented Jun 10, 2022

Issue Type: Bug

  1. Disable all extensions
  2. Open a node project workspace (that contains a node_modules folder) with no tabs open
  3. Run
    $ find /proc/*/fd -user "$USER" -lname anon_inode:inotify -printf '%hinfo/%f\n' 2>/dev/null | xargs cat | grep -c '^inotify'
    
    to print the number of file watchers
  4. Open a simple javascript file in the workspace
  5. Re-run the command above several times over the next 10 seconds or so
  6. You will get a number of file watchers that quickly goes up by something like 20,000 (probably depends on the number of packages in node_modules)

As a result I have started to get ENOSPC errors about reaching the Inotify limit, seems to be since upgrading to VSCode 1.67 (I'm not in control of the version).

This does not happen if you delete the node_modules folder.

I have the default **/node_modules/*/** in files.watcherExclude.

VS Code version: Code 1.67.2 (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5, 2022-05-17T18:23:40.286Z)
OS version: Linux x64 3.10.0-1160.66.1.el7.x86_64
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz (4 x 2599)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 0, 0, 0
Memory (System) 7.62GB (2.22GB free)
Process Argv --unity-launch --crash-reporter-id 4cb3165e-6680-471f-992f-0c1e623756f7
Screen Reader no
VM 100%
DESKTOP_SESSION 1-gnome
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP 1-gnome
XDG_SESSION_TYPE x11
Extensions: none
@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.68.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@bpasero
Copy link
Member

bpasero commented Jun 10, 2022

Probably caused by TypeScript and thus #46351. It is annoying that this issue is not getting attention to be honest.

@bpasero
Copy link
Member

bpasero commented Jun 10, 2022

Maybe this helps you @MetRonnie : https://www.typescriptlang.org/docs/handbook/configuring-watch.html

@mjbvz mjbvz transferred this issue from microsoft/vscode Jun 10, 2022
@mjbvz mjbvz removed Bug A bug in TypeScript typescript labels Jun 10, 2022
@mjbvz mjbvz removed their assignment Jun 10, 2022
@mjbvz
Copy link
Contributor

mjbvz commented Jun 10, 2022

@sheetalkamat Following up on #46351, would it be possible to either:

  1. Switch TS to robust watcher such as @parcel/watcher
  2. Let TS server be spun up with a custom watcher implementation (so that VS Code can make TS server use @parcel/watcher)
  3. Let TS Server delegate file watching to the VS Code TS extension? The extension would then use VS Code apis for watching files (behind the scenes this would use @parcel/watcher)

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 10, 2022
@MetRonnie
Copy link
Author

MetRonnie commented Jun 13, 2022

Maybe this helps you @MetRonnie : https://www.typescriptlang.org/docs/handbook/configuring-watch.html

Thanks! I have had some success with

// <project-root>/jsconfig.json
"watchOptions": {
    "excludeFiles": ["**/node_modules"]
}

seems to cut the number of watchers down by half. (Note: it has to be excludeFiles, for some reason excludeDirectories didn't work)

This suggestion also seems to have a similar effect:

// <project-root>/.vscode/settings.json
"typescript.disableAutomaticTypeAcquisition": true

(however, combining the two does not seem to be any better than only choosing one)

@richtera
Copy link

Fyi: Recent upgrades seems to have improved my instances out of inotify problems microsoft/vscode#151947 which was probably related to this issue

@logesh14
Copy link

#off-topic/irrelavent.

Do tsserver or vscode have any preferences to exclude a directory from code intelligence in single workspace.
Tried file.exclude but no luck. reference [(https://github.com/microsoft/vscode-cpptools/issues/2192)]
@sheetalkamat

@sheetalkamat
Copy link
Member

Duplicate of #46351

@sheetalkamat sheetalkamat marked this as a duplicate of #46351 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

8 participants