Fix bridge startup on macOS (over-long Unix socket paths) and Windows discover test#259
Merged
Conversation
… discover test The bridge's Unix domain socket path is built under the mcpc home dir (~/.mcpc/bridges/<session>.<pid>.sock). When that resolves to a deep path — notably macOS temp dirs like /var/folders/.../T used by the E2E harness, or a long session name — it exceeds the OS sockaddr_un.sun_path limit (104 bytes on macOS/BSD, 108 on Linux). bind()/connect() then fails with ENAMETOOLONG and the bridge exits during startup, which broke every session-creating E2E test on macOS (both Node and Bun). getSocketPath() now falls back to a short, fixed-length path under the OS temp dir when the preferred path would exceed the limit; the CLI and bridge derive the same path deterministically. Cleanup (cleanupOrphanedSockets, clean all) and the bridge's socket-dir creation follow the relocated location. Also fix the Windows connect-discover E2E test, which wrote an MSYS path (/d/a/...) into a stdio config; native Windows node misreads it as a relative path on the current drive. Convert it with to_native_path() like the other stdio tests. Refs #248
A restarted bridge can reuse a just-killed PID and inherit the stale socket file left at that PID-based path. startBridge()'s waitForFile() sees the stale file and returns, so the immediate credential-delivery / health-check connect hits the dead socket with no retry — making a fast `mcpc @<session> restart` intermittently fail with "Failed to connect to bridge: connect ECONNREFUSED" (seen on CI at -p 6). BridgeClient.connect() now takes an optional retryTimeoutMs that retries transient errors (ECONNREFUSED/ENOENT) while a freshly spawned bridge is still (re)creating its socket. Applied to the post-spawn credential, x402 wallet, and health-check connects; other connects still fail fast. https://claude.ai/code/session_01DJLkPTmAfaayFiwnofxWEv
…econnect) Follow-up to the rapid-restart ECONNREFUSED fix: rather than passing retryTimeoutMs at each post-spawn connect, BridgeClient.connect() now retries transient socket errors (ECONNREFUSED/ENOENT) by default. This removes the repeated option and also covers SessionClient's reconnect-after-restartBridge paths, which hit the same stale-socket race but weren't passing the option. sendBridgeShutdown opts out with retryTimeoutMs: 0 — it targets an already-running bridge and force-kills if unreachable, so retrying makes no sense. https://claude.ai/code/session_01DJLkPTmAfaayFiwnofxWEv
Replace the fixed 75ms retry sleep with a base (50ms) plus random jitter (0-50ms) so many clients retrying at once (e.g. parallel bridges in tests) don't wake on the same cadence and hammer their sockets together. Average delay is unchanged (~75ms). https://claude.ai/code/session_01DJLkPTmAfaayFiwnofxWEv
jancurn
added a commit
that referenced
this pull request
Jun 3, 2026
On Windows, `mcpc connect` wrapped discovered/invalid config paths in double quotes (`"D:\...\mcp.json"`) because `formatPath` treated the backslash as shell-unsafe. Backslash is the path separator on Windows (safe unquoted in cmd/PowerShell) but a shell escape character on POSIX, so it's now treated as safe only on Windows. This also fixes the `connect-discover` e2e test that was failing on Windows. - Plain Windows paths (`C:\Users\foo\mcp.json`) render unquoted; paths with spaces stay quoted - POSIX output is unchanged - Added `formatPath` unit tests for both platforms Refs #259 https://claude.ai/code/session_01UNivY6TKwgTnNX4xB6n61t Co-authored-by: Claude <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.
The bridge's Unix socket path is built under the mcpc home dir, so a deep
MCPC_HOME_DIR(e.g. macOS/var/folders/...temp dirs, or a long session name) exceeded the OSsockaddr_unlimit (104 bytes macOS, 108 Linux) and the bridge crashed on startup — breaking every session-creating E2E test on macOS.getSocketPath()falls back to a short, deterministic temp-dir path when the natural path is too long (CLI and bridge agree on it)connect-discovertest that fed an MSYS path to a stdio configRefs #248
https://claude.ai/code/session_01DJLkPTmAfaayFiwnofxWEv