Description
When switching models in Reasonix Desktop, the codegraph built-in MCP server fails to restart with the error "1 MCP server(s) failed to start: codegraph". This occurs because the Windows named pipe used by the codegraph daemon becomes stale after the connection is abruptly broken during a model switch.
Environment
- Reasonix Desktop: latest (from
C:\Users\jihongfeng\AppData\Local\Programs\Reasonix\reasonix-desktop.exe)
- codegraph: v0.9.7 (bundled with Reasonix at
C:\Users\jihongfeng\AppData\Local\Reasonix\codegraph\v0.9.7\)
- OS: Windows x64
- Node.js: v24.12.0 (bundled with codegraph)
Steps to Reproduce
- Start Reasonix Desktop. codegraph daemon starts normally -
daemon.log shows Listening on \\.\pipe\codegraph-xxx (pid N, v0.9.7)
- Switch models in Reasonix (e.g. from deepseek-flash to deepseek-pro)
- The old codegraph daemon receives
socket error: write EPIPE and exits
- The new Reasonix session attempts to start a new codegraph daemon
- But the old named pipe
\\.\pipe\codegraph-0822707c9dc94e58 remains on Windows in a half-disconnected state
- The new daemon fails to bind ? Reasonix shows
"1 MCP server(s) failed to start: codegraph"
Root Cause
Reasonix Desktop creates a new tab/session when switching models, but it disconnects from the existing codegraph daemon without cleaning up the Windows named pipe. On Windows, named pipes are not automatically destroyed when the client disconnects abruptly. When Reasonix tries to launch a new codegraph daemon using the same pipe name, the stale pipe prevents binding.
The codegraph daemon itself works perfectly - it's just the pipe handover that's broken.
Evidence
daemon.log (after model switch):
[CodeGraph daemon] Listening on \\.\pipe\codegraph-0822707c9dc94e58 (pid 12292, v0.9.7). Idle timeout 300000ms.
[CodeGraph MCP] File watcher active - graph will auto-sync on changes
[CodeGraph daemon] socket error: write EPIPE
Stale named pipe persists on Windows:
\\.\pipe\codegraph-0822707c9dc94e58 ? remains after daemon exits
codegraph standalone works fine - tested independently:
codegraph status ? 4,909 files, 113,970 nodes, 296.39 MB, healthy ?
codegraph serve --mcp ? starts and accepts MCP connections normally ?
Suggested Fix
In Reasonix Desktop, when switching models/sessions:
- Gracefully shut down the codegraph daemon (send
SIGTERM or call codegraph commands to cleanly exit) instead of abruptly disconnecting the pipe
- Or ensure the Windows named pipe is properly cleaned up after disconnection
- Or have codegraph generate a new random pipe name per session, avoiding reuse of stale pipes
Workaround
In config.toml, set [codegraph] enabled = false to disable the built-in codegraph server. This avoids the error but loses code intelligence features.
Note to maintainers
This is a Reasonix Desktop integration issue, not a codegraph core bug. However, codegraph could also help by:
- Detecting stale named pipes on startup and cleaning them up
- Using a unique pipe name per daemon instance (e.g. append a random suffix)
- Handling the EPIPE more gracefully and attempting reconnection
Description
When switching models in Reasonix Desktop, the codegraph built-in MCP server fails to restart with the error
"1 MCP server(s) failed to start: codegraph". This occurs because the Windows named pipe used by the codegraph daemon becomes stale after the connection is abruptly broken during a model switch.Environment
C:\Users\jihongfeng\AppData\Local\Programs\Reasonix\reasonix-desktop.exe)C:\Users\jihongfeng\AppData\Local\Reasonix\codegraph\v0.9.7\)Steps to Reproduce
daemon.logshowsListening on \\.\pipe\codegraph-xxx (pid N, v0.9.7)socket error: write EPIPEand exits\\.\pipe\codegraph-0822707c9dc94e58remains on Windows in a half-disconnected state"1 MCP server(s) failed to start: codegraph"Root Cause
Reasonix Desktop creates a new tab/session when switching models, but it disconnects from the existing codegraph daemon without cleaning up the Windows named pipe. On Windows, named pipes are not automatically destroyed when the client disconnects abruptly. When Reasonix tries to launch a new codegraph daemon using the same pipe name, the stale pipe prevents binding.
The codegraph daemon itself works perfectly - it's just the pipe handover that's broken.
Evidence
daemon.log (after model switch):
Stale named pipe persists on Windows:
codegraph standalone works fine - tested independently:
Suggested Fix
In Reasonix Desktop, when switching models/sessions:
SIGTERMor callcodegraphcommands to cleanly exit) instead of abruptly disconnecting the pipeWorkaround
In
config.toml, set[codegraph] enabled = falseto disable the built-in codegraph server. This avoids the error but loses code intelligence features.Note to maintainers
This is a Reasonix Desktop integration issue, not a codegraph core bug. However, codegraph could also help by: