Skip to content

Fix daemon socket failing with EINVAL on long project paths - #219

Open
nsams wants to merge 4 commits into
mainfrom
claude/daemon-socket-path-length-17tacf
Open

Fix daemon socket failing with EINVAL on long project paths#219
nsams wants to merge 4 commits into
mainfrom
claude/daemon-socket-path-length-17tacf

Conversation

@nsams

@nsams nsams commented Aug 18, 2026

Copy link
Copy Markdown
Member

Summary

Fixed an issue where the dev-pm daemon would fail to start or connect when the project path is too long. Unix domain socket paths must fit into sockaddr_un.sun_path (108 bytes on Linux, 104 bytes on macOS), and deeply nested projects would exceed this limit when using absolute paths.

Key Changes

  • Centralized project root logic: Created chdirToProjectRoot() utility function in load-config.ts that changes the working directory to the project root (directory containing the config file)
  • Updated all commands to use relative socket paths: Modified connect.ts, auto-start-daemon.ts, and start-daemon.command.ts to:
    • Call chdirToProjectRoot() after loading the config
    • Reference the socket as .pm.sock (relative path) instead of constructing an absolute path
  • Increased test timeout: Raised the default timeout in runDevPm() from 1000ms to 5000ms to accommodate slower systems
  • Added comprehensive test: New e2e test verifies the daemon works correctly with socket paths exceeding the 108-byte limit by creating a deeply nested directory structure

Implementation Details

  • The daemon already changed into the project root, so this change makes all commands consistent with that behavior
  • By using relative paths (.pm.sock), the socket path is always short regardless of the project's location in the filesystem
  • The changeset documents this as a patch-level fix for the socket path issue

https://claude.ai/code/session_01E17p2FNAxnWQEmZ1XMJ1yu

claude added 3 commits August 17, 2026 15:46
Unix domain socket paths must fit into sockaddr_un.sun_path (108 bytes on
Linux, 104 on macOS). In deeply nested projects the path to .pm.sock exceeded
that limit, so binding/connecting failed with EINVAL (or ENOENT when the path
got truncated).

Add src/utils/socket.ts, which opens the socket with a path relative to its
directory (temporarily switching the cwd) whenever the absolute path is too
long, and use it for both the daemon's listen and the clients' connect.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E17p2FNAxnWQEmZ1XMJ1yu
Instead of deciding per call whether the absolute socket path still fits into
sockaddr_un and temporarily switching the cwd around bind()/connect(), the CLI
commands now change into the project root - like the daemon already did - and
always refer to the socket by its plain file name.

Also raise the default per-command timeout of the e2e helper, 1s is not enough
for the daemon auto-start on slow machines.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E17p2FNAxnWQEmZ1XMJ1yu
The helper derives the project root from the config file, it has nothing to do
with sockets. With it living next to loadConfig the socket file can simply be
referenced by its plain name again, so the socket util file is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E17p2FNAxnWQEmZ1XMJ1yu
@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for dev-process-manager canceled.

Name Link
🔨 Latest commit 1a5f44a
🔍 Latest deploy log https://app.netlify.com/projects/dev-process-manager/deploys/6a8402e1a70292000878d156

@nsams
nsams requested a review from VPS-Fabi August 18, 2026 06:25
@nsams nsams self-assigned this Aug 18, 2026
Comment thread src/dev-pm.e2e.test.ts Outdated
Comment thread src/utils/load-config.ts
Shut down the daemon started in the long directory in a finally block, afterEach
only takes care of the one in tmpDir.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E17p2FNAxnWQEmZ1XMJ1yu
@nsams
nsams requested a review from VPS-Fabi August 18, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants