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:
- Adds the
--tsserver-path flag to ensure the LSP uses the project's local engine and honors tsconfig.json exclusions.
- 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
- Open a project with a massive
node_modules (100k+ files).
- Configure
tsconfig.json to exclude node_modules.
- Start
opencode web and run a prompt or open a file to trigger the LSP.
- 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
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_modulesfolder and ignoring exclusions intsconfig.json.Specific data observed during the leak:
tsserver.jsprocess.lsofshowed over 100k handles to(deleted)directories innode_modules, suggesting a high-frequency watcher loop.The Fix:
I've submitted a PR (#19953) that:
--tsserver-pathflag to ensure the LSP uses the project's local engine and honorstsconfig.jsonexclusions.--ignore-node-modulesif notsconfig.jsonorjsconfig.jsonis 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
node_modules(100k+ files).tsconfig.jsonto excludenode_modules.opencode weband run a prompt or open a file to trigger the LSP.lsof -p <pid> | wc -land 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