fix: create socket dir before spawning session daemon - #1
Merged
Merged
Conversation
The launcher writes the detached daemon's log file into the per-user
socket directory (/tmp/bench-<uid>/) before spawning the daemon, but
that directory was only created later by the daemon itself when binding
its socket. On a clean /tmp (macOS reaps entries after ~3 days), opening
the log failed and the session never started:
error: spawning session daemon: open /tmp/bench-<uid>/bench-*.log: no such file or directory
ensureSession now calls api.EnsureSocketDir before opening the log,
reusing the same 0700 + symlink hardening the daemon applies when it
binds. The call is idempotent with the daemon's own, so the daemon path
is unchanged. ensurePrivateSocketDir is exported as EnsureSocketDir for
reuse from the cli package.
Note: EnsureSocketDir is a no-op for custom --socket/BENCH_SOCKET paths
outside the private dir, so a custom socket in a nonexistent directory
would still fail the same way; left as-is since that path is user-chosen
and net.Listen would surface a clear error there anyway.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ccakes
force-pushed
the
fix/session-daemon-socket-dir
branch
from
July 7, 2026 02:28
ab4cc16 to
54e616d
Compare
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.
Problem
Starting a session fails on a clean
/tmpwith:The launcher (
ensureSession) writes the detached daemon's.loginto the per-user socket directory/tmp/bench-<uid>/before spawning the daemon — but that directory is only created later by the daemon itself (Server.Start→EnsureSocketDir) when it binds its socket. macOS reaps/tmpentries after ~3 days, so a directory from a prior session is gone by the next launch and the log open (os.OpenFilewithO_CREATE, which does not create parents) fails withENOENT.Regression from the detachable-sessions feature in 0.6.9.
Fix
ensureSessionnow callsapi.EnsureSocketDir(sockPath)right before opening the log file, reusing the existing 0700 + symlink hardening the daemon already applies. The call is idempotent with the daemon's own, so the daemon path is unchanged.ensurePrivateSocketDiris exported asEnsureSocketDirso theclipackage can call it.Tests
internal/api/socketdir_test.go(drivesos.TempDir()viaTMPDIR):0700, and is idempotentVerification
Built a binary from the pre-fix
cli.goand reproduced the exact error on a clean slate; the fixed binary starts cleanly and creates the dir (drwx------) containing both the.log(0600) and.sock.gofmt -l,go vet ./...,golangci-lint run, andgo test ./...all clean.Note for reviewers
EnsureSocketDiris intentionally a no-op for custom--socket/BENCH_SOCKETpaths outside the private dir, so a custom socket in a nonexistent directory would still hit the same log-open failure. Left as-is: that path is user-chosen andnet.Listenwould surface a clear error there anyway. Happy to widen it if you'd prefer.🤖 Generated with Claude Code