Skip to content

fix: leave a live socket alone instead of taking over its path at startup - #431

Merged
arzafran merged 3 commits into
mainfrom
fix/socket-start-keeps-live-listener
Oct 15, 2026
Merged

arzafran merged 3 commits into
mainfrom
fix/socket-start-keeps-live-listener

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

Launching a second build of Programa (a bench, a staging copy, a build with a different bundle id) no longer knocks the running app's command line tool and agent hooks offline. The new copy used to delete the running app's socket and take it over, and the running app stayed unreachable until someone ran Restart CLI Listener.

Do not merge until the fix commit is on this PR. The first push is the failing test alone, so CI shows it catches the bug.

Summary

  • bindListenerSocket unlinked the socket path before binding without checking whether another app was listening there. fix: give windowless launches a window and stop them deleting another app's socket #426 stopped the same takeover on quit; this covers startup.
  • It now probes the path first. Only a path proven stale or missing is unlinked. A live listener fails as EADDRINUSE, and an inconclusive probe (for example EMFILE, or a listener owned by another user) fails with its errno, so the default path falls back to the user-scoped one (programa-<uid>.sock) instead of taking the incumbent's path. The CLI resolves the default path first whenever it is live, so the fallback never redirects it.
  • The bind-failure log now includes the path, stage and errno.

Test Plan

  • CI: testStartLeavesALiveListenerFromAnotherProcessInPlace fails on the test commit and passes once the fix is pushed.
  • Real apps: with production Programa running, launched a Release build with a different bundle id and no socket override. Production's socket kept the same inode and still answered ping, and the new build bound programa-501.sock.

…rtup

bindListenerSocket unlinked the socket path before binding without checking
whether another app was still listening there, so a second build launched
on the default path cut the running app's CLI and agent hooks off. Probe
the path first and treat a live listener as EADDRINUSE, which falls back to
the user-scoped path.
@arzafran
arzafran merged commit bd8a39f into main Oct 15, 2026
13 checks passed
@arzafran
arzafran deleted the fix/socket-start-keeps-live-listener branch October 15, 2026 20:00
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