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
When running codegraph serve --mcp inside opencode on WSL2 with the project on an NTFS mount (/mnt/d), the MCP server fails to start within opencode's 30-second initialization timeout. The same command works fine from a regular terminal (~440ms startup).
Environment
OS: WSL2 (Ubuntu) on Windows 11
Filesystem: NTFS via /mnt/d mount
Node: v24.14.1
CodeGraph: v0.7.12 (installed via npx @colbymchenry/codegraph)
Harness: opencode (MCP stdio)
Project: ~350 source files (Rust), no target/ in index (excluded)
Root Cause
The FileWatcher.start() method in dist/sync/watcher.js calls:
On NTFS mounts in WSL2, fs.watch({ recursive: true }) is extremely slow — even with only ~350 tracked source files. This blocks the MCP stdio handshake long enough to trigger opencode's 30s startup timeout.
Notably, this is not a cold-start or large-project issue. The project has no target/, no node_modules/, and only 352 source files. The slowness is intrinsic to recursive fs.watch on NTFS.
Current Workaround
I patched watcher.js to check for a CODEGRAPH_NO_WATCH environment variable:
start(){if(process.env.CODEGRAPH_NO_WATCH==='1'){console.error('[codegraph] File watching disabled via CODEGRAPH_NO_WATCH=1');returnfalse;}// ... original code}
This works perfectly — MCP starts in ~180ms, all tools function normally. The trade-off is no auto-sync on file changes (requires manual codegraph sync).
Suggested Fix
Add official support for disabling the file watcher:
Problem
When running
codegraph serve --mcpinside opencode on WSL2 with the project on an NTFS mount (/mnt/d), the MCP server fails to start within opencode's 30-second initialization timeout. The same command works fine from a regular terminal (~440ms startup).Environment
/mnt/dmountnpx @colbymchenry/codegraph)target/in index (excluded)Root Cause
The
FileWatcher.start()method indist/sync/watcher.jscalls:On NTFS mounts in WSL2,
fs.watch({ recursive: true })is extremely slow — even with only ~350 tracked source files. This blocks the MCP stdio handshake long enough to trigger opencode's 30s startup timeout.Notably, this is not a cold-start or large-project issue. The project has no
target/, nonode_modules/, and only 352 source files. The slowness is intrinsic to recursive fs.watch on NTFS.Current Workaround
I patched
watcher.jsto check for aCODEGRAPH_NO_WATCHenvironment variable:And set the env var in opencode config:
This works perfectly — MCP starts in ~180ms, all tools function normally. The trade-off is no auto-sync on file changes (requires manual
codegraph sync).Suggested Fix
Add official support for disabling the file watcher:
CODEGRAPH_NO_WATCH=1— skipfs.watchentirelycodegraph serve --mcp --no-watch/mnt/*) and warn/skip watcher automaticallyOption 1 is the least invasive and would solve this for all harness tools, not just opencode.
Related
fs.watchslowness on NTFS remains