Skip to content

Replace pm2-axon with homegrown solution - #2690

Merged
fredrikekelund merged 8 commits into
trunkfrom
stu-1301-replace-pm2-axon-with-homegrown
Mar 9, 2026
Merged

Replace pm2-axon with homegrown solution#2690
fredrikekelund merged 8 commits into
trunkfrom
stu-1301-replace-pm2-axon-with-homegrown

Conversation

@fredrikekelund

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

I wrote the initial plan and then relied on Codex to produce the initial implementation. I've since iterated on apps/cli/lib/socket.ts over multiple rounds, touching almost every part of it. The tests are auto-generated. I've barely touched them. I've reviewed all code and manually tested Studio to ensure that site events are emitted the same as before.

Proposed Changes

In #2398, we adopted a socket-based solution for sending site events from the CLI to Studio. We opted to use the pm2-axon module for this. It's a thin library, but it offers some conveniences when working with sockets, and it was already in our dependency tree.

We've since found that pm2-axon can easily be replaced with a homegrown solution that uses modules from the Node.js standard library. This will help significantly with maintainability and long-term stability.

This PR removes the direct pm2-axon dependency in favor of apps/cli/lib/socket.ts

Testing Instructions

  1. Run npm start
  2. Ensure that starting and stopping sites works as expected and that the UI updates accordingly.
  3. Run node apps/cli/dist/cli/main.js site start --skip-browser --path PATH_TO_SITE and ensure that the Studio UI is updated when the site starts

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@fredrikekelund
fredrikekelund requested review from a team and bcotrim March 3, 2026 09:51
@fredrikekelund fredrikekelund self-assigned this Mar 3, 2026
@wpmobilebot

wpmobilebot commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 7b314fe vs trunk

site-editor

Metric trunk 7b314fe Diff Change
load 1771.00 ms 1756.00 ms -15.00 ms ⚪ 0.0%

site-startup

Metric trunk 7b314fe Diff Change
siteCreation 7134.00 ms 7117.00 ms -17.00 ms ⚪ 0.0%
siteStartup 3928.00 ms 3944.00 ms +16.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim bcotrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍
I didn't find any regressions!

Nit: I am not sure about the socket dependency on pm2-manager, but since that's going to be refactored in another PR it's probably not an issue anymore, I haven't reviewed #2712 yet.

@fredrikekelund

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @bcotrim 👍

I am not sure about the socket dependency on pm2-manager

Do you mean pm2-manager.ts's dependency on socket.ts?

@fredrikekelund
fredrikekelund merged commit b47694c into trunk Mar 9, 2026
10 checks passed
@fredrikekelund
fredrikekelund deleted the stu-1301-replace-pm2-axon-with-homegrown branch March 9, 2026 07:27
@bcotrim

bcotrim commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for the review, @bcotrim 👍

I am not sure about the socket dependency on pm2-manager

Do you mean pm2-manager.ts's dependency on socket.ts?

Yes, but I think the complete solution on #2712 is cleaner and makes sense. 👍

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

Labels

None yet

3 participants