Repository navigation
Description
Affected component
runtime/daemon
Severity
S1 - workflow blocked
Current behavior
Two unguarded operations in crates/zeroclaw-runtime/src/rpc/local.rs let any second daemon break the first, and then break the socket for everyone:
- Start steals the path.
platform::remove_stale(&path)(line 136) deletes an existingdaemon.sockbefore binding, with no liveness check. A second daemon silently takes the path from a running first one, which stays alive but becomes unreachable. - Exit unlinks a path it may no longer own.
platform::cleanup(&path)(line 224) callsremove_fileunconditionally on shutdown, without checking the path still resolves to this listener's socket. An exiting daemon deletes a socket a different process bound since.
Combined: daemon B starts and steals A's path; A is alive but unreachable. Later B exits and cleanup removes the path — now nothing is reachable, even though A is still running and looks healthy in ps. Recovery requires noticing and restarting, because both ps and the service manager report a healthy daemon.
Observed three times while debugging an unrelated change.
Expected behavior
A daemon should not take a socket that a live daemon is serving — it should detect the live peer and refuse to start (or bind elsewhere) rather than silently stealing it.
A daemon should not unlink a socket path it no longer owns.
Steps to reproduce
# 1. Start a daemon and confirm it serves the socket.
zeroclaw daemon &
lsof ~/.zeroclaw/data/daemon.sock # -> PID A
# 2. Start a second daemon against the same config dir.
zeroclaw daemon &
lsof ~/.zeroclaw/data/daemon.sock # -> PID B; A is now unreachable
# 3. Stop the second one.
kill <PID B>
# 4. The path is gone, though A is still running.
ls ~/.zeroclaw/data/daemon.sock # No such file or directory
ps -p <PID A> # still alive, still "healthy"Impact
Every local client breaks while the daemon appears healthy, so the failure is silent until someone tries to use it. ps shows a running daemon and the launch agent reports the service as loaded, which sends you looking in the wrong place.
Two paths make this reachable in a stock install rather than only under manual use:
- The desktop app spawns its own daemon when its health probe finds nothing. That probe uses a hardcoded port (
const GATEWAY_PORT: u16 = 42617inapps/tauri/src/lib.rs) and never reads the configuredgateway.port, so any user on a different port gets a probe that cannot succeed and a duplicate daemon on every launch. The probe window is also 3 x 700ms, shorter than observed daemon readiness. - A launch agent plus any manual
zeroclaw daemonproduces the same collision.
Running additional daemons under their own ZEROCLAW_CONFIG_DIR isolates them correctly and is a sound workaround for development.
Logs / stack traces
zerocode: zerocode connected to the daemon, but initialization did not finish within 10s. Restart the daemon and try again.
No such file or directory (os error 2)
ZeroClaw version
0.8.4 (release binary; code paths confirmed on master 0c8c92e)
Rust version
rustc 1.96.1
Operating system
macOS 26.5.2
Regression?
Unknown
Pre-flight checks
- I reproduced this on the latest master branch or latest release.
- I redacted secrets, tokens, and personal data from all submitted content.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
vyahhi commentedon Aug 9, 2026
[AUTO] Related: #9846 is the focused implementation for this daemon socket-ownership bug. Both preserve the live incumbent daemon endpoint and still allow genuine stale-socket recovery. Difference: this issue records the process-level failure, while #9846 probes an existing listener and tracks device/inode ownership so startup and shutdown cannot steal or unlink another listener socket.