Skip to content

LSP causes client to watch thousands of files #64062

Description

@CamJN

🔎 Search Terms

watchers, workspace/didChangeWatchedFiles, globPattern

🕗 Version & Regression Information

I believe this changed between versions 6 and 7, but due to a variety of circumstances I'm not 100% sure.

⏯ Playground Link

No response

💻 Code

N/A the code is not relevant, just the number of files in the project.

🙁 Actual behavior

the lsp server sends roughly the following to the client:

{
  "jsonrpc": "2.0",
  "method": "client/registerCapability",
  "params": {
    "registrations": [
      {
        "id": "root files for ~/Developer/Typescript/webapp/tsconfig.json watcher 8.0",
        "method": "workspace/didChangeWatchedFiles",
        "registerOptions": {
          "watchers": [
            {
              "globPattern": "~/Developer/Typescriptwebapp/**/*",
              "kind": 7
            }
          ]
        }
      }
    ]
  }
}

The globPattern causes the client to watch every file and directory in the project, which between the .git dir and node_modules is easily several thousand files (62,410 in the project I'm currently working on), which causes the client to run our of file descriptors.

🙂 Expected behavior

The globPattern should only watch the files in dirs mentioned in tsconfig's includes list, or at the very least just files with ts, tsx, js, jsx, or mjs extensions.

Additional information about the issue

I'm trying to use tsc in lsp mode with emacs' eglot but finding that it breaks the editor by quickly using up all of the file descriptors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions