redhat-developer / vscode-openshift-tools

OpenShift extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-openshift-connector
MIT License
95 stars 61 forks source link

"too many files open" while running tests #3120

Open datho7561 opened 1 year ago

datho7561 commented 1 year ago

While trying to develop a test for Component Command execution I'm still running into too many files open error. And I found that actually the problem happens a long before the actual test is executed, see the log output of npm test:

Loading development extension at /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User')
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User/settings.json for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User/settings.json')
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/test/fixtures/components/empty.code-workspace for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/test/fixtures/components/empty.code-workspace')
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/vscode-linux-x64-1.81.1/resources/app/extensions/theme-defaults/fileicons/vs_minimal-icon-theme.json for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/vscode-linux-x64-1.81.1/resources/app/extensions/theme-defaults/fileicons/vs_minimal-icon-theme.json')
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/vscode-linux-x64-1.81.1/resources/app/extensions/theme-abyss/themes/abyss-color-theme.json for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/vscode-linux-x64-1.81.1/resources/app/extensions/theme-abyss/themes/abyss-color-theme.json')
[vscode.php]: One or more snippets from the extension 'php' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)
[File Watcher (node.js)] Failed to watch /home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User/snippets for changes using fs.watch() (Error: EMFILE: too many open files, watch '/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/.vscode-test/user-data/User/snippets')
(node:636849) Warning: Accessing non-existent property 'VERSION' of module exports inside circular dependency
(Use `exe --trace-warnings ...` to show where the warning was created)
[636539:0824/013338.891900:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
  odo commands integration component
[636539:0824/013349.566429:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
      1) runCompobentCommand()
  Suite duration: 14.898 s, Tests: 1
  0 passing (20s)
  1 failing
  1) odo commands integration
       component
         runCompobentCommand():
     AssertionError [ERR_ASSERTION]: Start Dev failed:  ✗  too many open files

      at Context.<anonymous> (test/integration-partial/command.test.ts:210:25)
      at Generator.next (<anonymous>)
      at fulfilled (out/test/integration-partial/command.test.js:9:58)

No coverage information was collected, exit without writing coverage information
Error: 1 tests failed
    at Object.<anonymous> (/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/test/integration-partial/index.ts:65:15)
    at Generator.next (<anonymous>)
    at fulfilled (/home/jeremy/projects/vscode-openshift-tools/source/vscode-openshift-tools/out/test/integration-partial/index.js:5:58)
[main 2023-08-23T23:33:57.231Z] Extension host with pid 636849 exited with code: 0, signal: unknown.
Exit code:   1
Failed to run tests

Originally posted by @vrubezhny in https://github.com/redhat-developer/vscode-openshift-tools/issues/2811#issuecomment-1691597323

datho7561 commented 1 year ago

There are many cases where we don't dispose of file watchers properly. This is one step we could take to avoid this problem, since on Linux file watchers count as opened files.

datho7561 commented 1 year ago

esbuild appears to be using an ever-increasing amount of RAM while running on Windows. Maybe this is related. I should take a look at the esbuild watch script that I wrote as well as a part of this investigation.