Skip to content

Critical Resource Exhaustion in TypeScript LSP (v1.3.5) #19952

@derekbar90

Description

@derekbar90

Description

My system was freezing and SSH sessions were being killed because Opencode was opening over 190,000 file descriptors. It turns out the TypeScript LSP is indexing the entire node_modules folder and ignoring exclusions in tsconfig.json.

Specific data observed during the leak:

  • FD Count: Peaked at 194,473 open descriptors on the tsserver.js process.
  • Memory usage: Process RSS spiraled from 3GB to 21GB, exhausting swap and lagging the host OS.
  • Ghost handles: lsof showed over 100k handles to (deleted) directories in node_modules, suggesting a high-frequency watcher loop.

The Fix:
I've submitted a PR (#19953) that:

  1. Adds the --tsserver-path flag to ensure the LSP uses the project's local engine and honors tsconfig.json exclusions.
  2. Adds a fallback safeguard that automatically applies --ignore-node-modules if no tsconfig.json or jsconfig.json is found in the project root.

I've confirmed this fix resolves the leak and restores system stability.

Plugins

@opencode-ai/plugin, typescript

OpenCode version

1.3.5

Steps to reproduce

  1. Open a project with a massive node_modules (100k+ files).
  2. Configure tsconfig.json to exclude node_modules.
  3. Start opencode web and run a prompt or open a file to trigger the LSP.
  4. Check lsof -p <pid> | wc -l and you'll see the count skyrocket regardless of the config.

Screenshot and/or share link

N/A - Resource exhaustion issue

Operating System

Ubuntu 24.04

Terminal

bash / Warp

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions