You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dsh web: code-index leaks one file descriptor per indexed file (9k+ FDs after 4 days)
#4516
After running dsh web for ~4 days, the node process accumulates 9,441 open REG file descriptors — almost all of them are source files from a single project directory (.java, pom.xml, etc.), 9,440 unique files, plus a permanently-open .dsh/code-index/index.sqlite-shm.
Verified with lsof -p <pid>: the FD set is dominated by files that were clearly scanned once by the code-index feature and then never closed. The process holds ~37% of all open files on the machine, and it grows monotonically until the process is restarted.
Impact
A single long-running dsh web process can eventually push the system toward kern.maxfiles, causing unrelated processes (e.g. Bun-based CLIs like opencode) to fail with EMFILE/"low max file descriptors" errors. In our case a separate tool started failing with EMFILE (Unexpected) while the system was only at 17% of the global limit.
Repro
Start dsh web.
Have it build a code index over a project (.dsh/code-index/).
Run lsof -p <dsh pid> | awk '$5=="REG"' | wc -l after a few hours/days — FD count grows and only resets on restart.
Workaround
Restart dsh web periodically. In our case FD count went from 9,441 → 52 after restart.
Suggested fix
Close file handles after each file is indexed (or read files in batches/streams with a bounded concurrency limit) so the indexer doesn't retain a handle per scanned file.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Environment
dsh0.1.0-rc.8 (@deepseek-ai/dsh, apps/cli)node .../lib/bin.js web)Symptom
After running
dsh webfor ~4 days, the node process accumulates 9,441 open REG file descriptors — almost all of them are source files from a single project directory (.java,pom.xml, etc.), 9,440 unique files, plus a permanently-open.dsh/code-index/index.sqlite-shm.Verified with
lsof -p <pid>: the FD set is dominated by files that were clearly scanned once by the code-index feature and then never closed. The process holds ~37% of all open files on the machine, and it grows monotonically until the process is restarted.Impact
A single long-running
dsh webprocess can eventually push the system towardkern.maxfiles, causing unrelated processes (e.g. Bun-based CLIs like opencode) to fail withEMFILE/"low max file descriptors" errors. In our case a separate tool started failing withEMFILE (Unexpected)while the system was only at 17% of the global limit.Repro
dsh web..dsh/code-index/).lsof -p <dsh pid> | awk '$5=="REG"' | wc -lafter a few hours/days — FD count grows and only resets on restart.Workaround
Restart
dsh webperiodically. In our case FD count went from 9,441 → 52 after restart.Suggested fix
Close file handles after each file is indexed (or read files in batches/streams with a bounded concurrency limit) so the indexer doesn't retain a handle per scanned file.
All reactions