Skip to content

Fix site start/stop status by removing stale socket file - #2534

Merged
bcotrim merged 1 commit into
trunkfrom
fix-site-start-stop-status
Feb 5, 2026
Merged

Fix site start/stop status by removing stale socket file#2534
bcotrim merged 1 commit into
trunkfrom
fix-site-start-stop-status

Conversation

@bcotrim

@bcotrim bcotrim commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

  • Remove stale Unix socket file (~/.studio/pm2/events.sock) before binding in the _events command
  • Only applies to Unix-based systems (macOS/Linux) since Windows named pipes are automatically cleaned up by the OS

Root cause: When Studio crashes or is force-killed, the socket file is left behind. On restart, the _events command cannot bind to this socket (EADDRINUSE), preventing site-event updates from flowing to the UI.

Testing Instructions

  1. Start Studio in dev mode (npm start)
  2. Verify normal start/stop works - click Start/Stop on a site, status should update
  3. Force-kill Studio without proper cleanup:
    pkill -9 -f "Electron.app"
  4. Verify the stale socket file exists:
    ls -la ~/.studio/pm2/events.sock
  5. Start Studio again (npm start)
  6. Click Start/Stop on a site - status should update correctly (the fix removes the stale socket automatically)

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@bcotrim bcotrim self-assigned this Feb 4, 2026
@bcotrim
bcotrim requested a review from a team February 4, 2026 19:02
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 611152d vs trunk

site-editor

Metric trunk 611152d Diff Change
load 2921.00 ms 2914.00 ms -7.00 ms 🟢 -0.2%

site-startup

Metric trunk 611152d Diff Change
siteCreation 7091.00 ms 7112.00 ms +21.00 ms 🔴 0.3%
siteStartup 3929.00 ms 3921.00 ms -8.00 ms 🟢 -0.2%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! it solved my issue! 👌
Now I can see the sites starting and stopping as expected.

@bcotrim
bcotrim merged commit f694c0b into trunk Feb 5, 2026
14 checks passed
@bcotrim
bcotrim deleted the fix-site-start-stop-status branch February 5, 2026 08:19
@fredrikekelund

Copy link
Copy Markdown
Contributor

pm2-axon is supposed to automatically handle EADDRINUSE errors in Socket::bind. See source.

The gist of the logic is that:

  • If net.createServer emits an EADDRINUSE error.
    • Create a net.Socket and try to connect to the socket.
    • If this fails, it means that no server is listening on the socket, so pm2-axon removes the socket file and connects again.

If this fixes the underlying problem, that's great 👍 Still, I'm curious how the pm2-axon logic fails and why…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants