Skip to content

mcpx: preserve regular files at the Unix socket path during daemon startup #5742

Closed

Description

@dezren39

Problem

Daemon startup can delete a regular file that happens to occupy the configured Unix socket path. In pkgs/mcpx/internal/daemon/server.go, the cleanup path around lines 342–345 and 479–489 attempts a Unix dial and removes the path whenever dialing fails. A regular file is not a live socket, so the failed dial is followed by os.Remove and its contents are lost before the daemon binds.

A stale Unix socket should be removable, but an unrelated regular file or symlink must not be treated as stale socket state.

Required behavior

Inspect the path type before removal. Remove only a stale socket file after confirming it cannot be connected to; for any non-socket filesystem entry, preserve it and return a clear startup error that identifies the collision.

Acceptance criteria

  • A test creates a regular file at the configured socket path, attempts daemon startup, and asserts startup fails while the file contents remain unchanged.
  • A stale Unix socket at that path is still cleaned up and startup succeeds.
  • An active socket remains protected and is not removed.
  • Cover custom MCPX_SOCKET and the default socket path through the same cleanup helper where possible.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    on Nov 5, 2026
  2. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  3. added
    queue/queuedHas a queued task in the Supabase agent queue
    task/triageQueue packet kind: verify, reproduce, and route this item
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  4. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  5. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 5, 2026
  6. 146 remaining items

  7. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-code-y (lane code-y, repo-queue-worker-shift-y) in FALLBACK MODE (backend down: fleet queue health HTTP 503 PGRST002).

    🤖 Agent note · picked up

  8. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 7, 2026
  9. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Heartbeat by repo-worker-code-y (lane code-y, FALLBACK MODE): implementation complete on laptop worktree ~/git/fleet/queue-5742-mcpx-socket-guard (branch queue/5742-mcpx-socket-guard) — clearStaleSocket now Lstats the path and refuses to remove any non-socket entry (regular file, symlink, directory) with a startup error naming the collision; stale-socket removal and active-socket protection unchanged. New tests in stale_socket_test.go cover all four acceptance cases plus the absent-path no-op. ServeInline disposition: its unconditional remove targets its own private per-process socket it just created the path for, not the daemon's configured path — left unchanged, noted here per criterion 4. Next: push, PR, CI, merge.

  10. added 2 commits that reference this issue on Nov 7, 2026
  11. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Released done by repo-worker-code-y (lane code-y, FALLBACK MODE): issue #5742 fixed and merged via PR #6738 (merge e5916a6); issue closed by the PR.

    🤖 Agent note · done

    Outcome

    • clearStaleSocket now Lstats the socket path: non-socket entries (regular file, symlink, directory) are preserved and startup fails naming the collision; stale sockets are still removed after a failed dial; active sockets still return the already-listening error.
    • Tests: 6 new tests in stale_socket_test.go (regular file, symlink, symlink-to-stale-socket [added for a Codex P1 finding, fixed in-PR with a thread reply], stale socket, active socket, absent path) — all PASS on the laptop: go test ./internal/daemon/ -run TestClearStaleSocket -count=1.
    • ServeInline disposition and cross-repo note stand as recorded in the heartbeat above (no darwin-nix change owed; fix propagates via the package pin).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions