Skip to content

fix(daemon): don't touch the env-derived socket dir when binding to explicit paths - #16

Merged
msmps merged 1 commit into
mainfrom
fix/bind-global-socket-dir-race
Jul 11, 2026
Merged

fix(daemon): don't touch the env-derived socket dir when binding to explicit paths#16
msmps merged 1 commit into
mainfrom
fix/bind-global-socket-dir-race

Conversation

@msmps

@msmps msmps commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the intermittent CI failure in test_client_connects_to_running_daemon (seen on ubuntu in the #14 run and on macos on the v0.0.8 bump commit, run 29156160576):

Failed to bind server: Failed to create socket directory
Caused by: Read-only file system (os error 30)

Root cause

bind_to() unconditionally called paths::ensure_socket_dir(), which resolves the global socket directory from PILOTTY_SOCKET_DIRXDG_RUNTIME_DIRHOME → tempdir. The paths tests mutate those exact env vars, serialized by a mutex — but only against each other. Env vars are process-global, so daemon/client tests running in parallel could observe a mid-test poisoned value and try to create a directory on an unwritable path.

Fix

bind_to() receives explicit paths and already creates the socket's parent directory two lines later — the env-derived global dir was never its business. Preparing that directory (with 0700) moves to bind(), the production entry point that derives paths from the environment. bind_to now has zero dependency on global env state, which removes the race structurally rather than tuning test ordering.

No production behavior change: bind() still prepares the default directory before delegating.

Verification

Five consecutive full-suite runs green locally; clippy clean under -D warnings; fmt clean.

🤖 Generated with Claude Code

…xplicit paths

bind_to() unconditionally called paths::ensure_socket_dir(), which
resolves the global socket directory from PILOTTY_SOCKET_DIR,
XDG_RUNTIME_DIR, or HOME. The paths tests mutate those env vars under a
mutex that only serializes the paths tests against each other — env vars
are process-global, so a daemon test calling bind_to in parallel could
read a poisoned value and fail with 'Read-only file system' while
creating the directory. Seen intermittently in CI on both platforms
(test_client_connects_to_running_daemon).

bind_to receives explicit paths and already creates the socket's parent
directory; preparing the env-derived default directory belongs in
bind(), the production entry point. Moving it removes bind_to's
dependency on global environment state entirely.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@msmps
msmps merged commit b9e9a43 into main Jul 11, 2026
6 checks passed
@msmps
msmps deleted the fix/bind-global-socket-dir-race branch July 11, 2026 14:40
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.

1 participant