Skip to content

Timeout site stop --all after 6s when quitting#2475

Merged
fredrikekelund merged 3 commits intotrunkfrom
f26d/timeout-stop-all-command
Feb 17, 2026
Merged

Timeout site stop --all after 6s when quitting#2475
fredrikekelund merged 3 commits intotrunkfrom
f26d/timeout-stop-all-command

Conversation

@fredrikekelund
Copy link
Copy Markdown
Contributor

@fredrikekelund fredrikekelund commented Jan 26, 2026

Related issues

Proposed Changes

When Studio quits, the stopAllServers function runs the site stop --all CLI command to stop running sites. This function resolves if the command fails or if the Node.js ChildProcess instance emits an error event.

Unfortunately, when testing the Studio 1.7.0 Intel build on my Apple Silicon laptop (using Rosetta emulation) none of these things appear to happen. I don't yet know what happens for regular macOS Intel users, but there are some indications that stopAllServers does resolve. In any case, it's likely not working for me because the bundled node runtime initializes but can't proceed, getting stuck in an intermittent state.

To mitigate against similar issues in the future, this PR adds an optional timeout to the stopAllServers function that kills the child process and resolves the promise.

Testing Instructions

  1. Run npm start
  2. Wait a second or two
  3. Quit the app
  4. Ensure that it exits cleanly

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from a team January 26, 2026 11:36
@fredrikekelund fredrikekelund self-assigned this Jan 26, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Jan 26, 2026

📊 Performance Test Results

Comparing bbdb78f vs trunk

site-editor

Metric trunk bbdb78f Diff Change
load 2697.00 ms 2707.00 ms +10.00 ms ⚪ 0.0%

site-startup

Metric trunk bbdb78f Diff Change
siteCreation 6073.00 ms 6079.00 ms +6.00 ms ⚪ 0.0%
siteStartup 3930.00 ms 3926.00 ms -4.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

Copy link
Copy Markdown
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

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

Changes LGTM, and the process still exists cleanly.

Image

Copy link
Copy Markdown
Contributor

@epeicher epeicher left a comment

Choose a reason for hiding this comment

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

Thanks @fredrikekelund! I have tested it, and I can see that the application exits cleanly after different amounts of time. I left a minor comment, but this can progress anyway. LGTM!

Image

Comment thread src/index.ts
if ( shouldStopSitesOnQuit ) {
event.preventDefault();
stopAllServers( true )
stopAllServers( true, 6_000 )
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.

Nit: I think adding a constant with a meaningful name would help to identify what this number is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the function argument name already provides similar clarity. Extracting the value into a constant would also introduce a jump for the reader between where the value is defined and this, the only place where it's used. So, in this particular case, I'll go ahead and land it as is 👍

@fredrikekelund
Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, @gcsecsey and @epeicher 🙏 This fell by the wayside as I was sick and then AFK. Coming back and landing this now.

@fredrikekelund fredrikekelund merged commit 514e409 into trunk Feb 17, 2026
9 of 10 checks passed
@fredrikekelund fredrikekelund deleted the f26d/timeout-stop-all-command branch February 17, 2026 13:41
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.

4 participants