fix(mcp): fall back to tmpdir socket on filesystems without AF_UNIX support#998
Open
zengwenliang416 wants to merge 1 commit into
Open
fix(mcp): fall back to tmpdir socket on filesystems without AF_UNIX support#998zengwenliang416 wants to merge 1 commit into
zengwenliang416 wants to merge 1 commit into
Conversation
…upport (colbymchenry#997) ExFAT, NTFS-3G, and some FUSE-backed volumes do not support Unix domain sockets — `listen()` fails with ENOTSUP. `getDaemonSocketPath` already had a tmpdir fallback for long paths; this extends it to also probe socket support via a short-lived child process, cached per device. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #997.
getDaemonSocketPath()now probes whether the target directory supports Unix domain sockets before returning an in-project path. On filesystems that don't support AF_UNIX (ExFAT, NTFS-3G, some FUSE mounts), it transparently falls back to theos.tmpdir()hash-based socket — the same path already used for the long-path case.Problem
When a project lives on an ExFAT-formatted external volume (common on macOS for USB drives), the daemon fails to start:
The existing tmpdir fallback only triggered for paths exceeding 100 characters. Short paths on unsupported filesystems had no fallback.
Approach
canSocketInDir(dir)todaemon-paths.tsthat spawns a short-lived child process (execFileSync) to attempt binding a Unix socket in the target directoryfs.statSync().dev) so the probe runs at most once per mounted filesystem per process lifetimegetDaemonSocketPath()alongside the existing length checkgetDaemonSocketPath(), so they automatically agree on the socket path — no changes needed indaemon.tsorindex.tsChanges
src/mcp/daemon-paths.ts: AddedcanSocketInDir(),clearSocketSupportCache()(test helper), updatedgetDaemonSocketPath()guard__tests__/daemon-socket-probe.test.ts: New test file covering probe behavior and cache semanticsTest plan
npm run build— compiles cleanlycanSocketInDirreturns true on tmpdir, caches results, handles nonexistent dirsdaemon-bind-failure.test.tsstill passes (no regression)proxy-connect.test.tsanddaemon-registry.test.tsstill passgetDaemonSocketPath('/Volumes/exfat-drive/project')returns tmpdir path; local APFS projects still get in-project path