fix(daemon): clear stale named pipe on Windows before bind (#723)#726
Open
GuruyuganKarthik8377 wants to merge 1 commit into
Open
fix(daemon): clear stale named pipe on Windows before bind (#723)#726GuruyuganKarthik8377 wants to merge 1 commit into
GuruyuganKarthik8377 wants to merge 1 commit into
Conversation
…nry#723) On Windows, named pipes left over from an abruptly-disconnected daemon (e.g. a Reasonix model-switch that sends EPIPE) cannot be unlinked like POSIX sockets. The previous cleanup block was gated to non-Windows only, so the stale pipe caused the next daemon's listen() to fail with EADDRINUSE. Fix: probe the pipe with a short connect attempt before listen(). A refused or absent pipe means the name is stale and Windows will release it; a successful connect means a live daemon is present and we leave it alone. The probe always resolves — a timeout or unexpected error is treated as stale so startup is never blocked. Fixes colbymchenry#723
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #723
Root cause
The
start()cleanup block that clears stale sockets beforelisten()was gated to
process.platform !== 'win32', so on Windows the stalenamed pipe was never cleared. When Reasonix switches models and abruptly
disconnects, the old pipe lingers and the new daemon fails to bind with
EADDRINUSE.Fix
Added
probeAndClearWindowsPipe()— a fail-safe connect probe that runson Windows before
listen().Changes
src/mcp/daemon.tsonly — no other files touchedunlinkSyncblock unchanged)Testing
npm run build