aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.51k stars 436 forks source link

ci: "Failed to watch node_modules/…/package.json using fs.watch() … ENOSPC" #5495

Open justinmk3 opened 2 months ago

justinmk3 commented 2 months ago

Problem

The Linux Unit Tests CI jobs show these (non-fatal, currently) errors indicating that something is crawling files in node_modules and trying to watch package.json

[File Watcher (parcel)] Inotify limit reached (ENOSPC) (path: /codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules)
  file_editAwsFile telemetry
[File Watcher (node.js)] Failed to watch /codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/readline-sync/package.json for changes using fs.watch() (Error: ENOSPC: System limit for number of file watchers reached, watch '/codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/readline-sync/package.json')
[File Watcher (node.js)] Failed to watch /codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/responselike/package.json for changes using fs.watch() (Error: ENOSPC: System limit for number of file watchers reached, watch '/codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/responselike/package.json')
[File Watcher (node.js)] Failed to watch /codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/retry/package.json for changes using fs.watch() (Error: ENOSPC: System limit for number of file watchers reached, watch '/codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/retry/package.json')
[File Watcher (node.js)] Failed to watch /codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/semver/package.json for changes using fs.watch() (Error: ENOSPC: System limit for number of file watchers reached, watch '/codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/node_modules/@types/semver/package.json')
Unable to load and parse grammar for scope source.ssmjson from file:///codebuild/output/src4054755577/src/github.com/aws/aws-toolkit-vscode/packages/core/syntaxes/SSMJSON.tmLanguage { fileOperationResult: 1, options: { preferUnbuffered: true } }
    ✔ emits when opened by user (488ms)

Expected behavior

Toolkit/Q code should not create lots of file watchers. #2382 (Good news: this may be a CI-only issue; see "Analysis" below.)

This issue is currently not "fatal" (doesn't fail CI or interfere with tests ... yet). But:

  1. it may point to a problem that affects actual users (on Linux if not other OSes)
  2. it adds noise to the CI logs
  3. it may interfere with tests in the future

Analysis

justinmk3 commented 1 week ago

This is becoming much more frequent, for example https://github.com/aws/aws-toolkit-vscode/pull/5944

Potential solution: add "**/node_modules/**" to the files.watcherExclude vscode setting, before running tests in CI.