Skip to content

Conversation

@fredrikekelund
Copy link
Contributor

@fredrikekelund fredrikekelund commented Dec 19, 2025

Related issues

Proposed Changes

This PR fixes the Windows E2E tests by making the following changes:

  • Disconnect from pm2 in the site list --watch command in response to SIGINT and SIGTERM signals. Without this, the site list --watch command couldn't be aborted with Ctrl+C and it would interfere with closing the Electron app.
  • Revert the changes from Sync site list when CLI creates sites while app is running #2313, because they make the E2E tests fail. See Sync site list when CLI creates sites while app is running #2313 (comment)
  • Modify the site stop --all command to kill all pm2 processes in one go, including the daemon itself.
  • Refactor E2ESession::cleanup to not call ElectronApplication::close(), but always use electronApp.evaluate( ( { app } ) => app.quit() ).
  • Wait for the stopAllServersOnQuit child process to finish before exiting the Electron app. This ensures all child processes have ended once the app quits, allowing auto-updates to be gracefully applied (if the bundled Node.js runtime were still used to run child processes, it would not be updatable on Windows).
  • Kill child processes in response to will-quit Electron event.
  • Clean up E2E session files after a slight delay, and use rimraf for smart retry behavior.
  • Playground was logging warnings about themeZipFile and pluginZipFile being deprecated, so I also took the opportunity to replace those keys with themeData and pluginData in the test fixtures.
  • Start the site watcher (site list --watch) and wait for the spawn event from the child process before creating the main app window. After working on this for so long, I doubt this makes any difference, but it still seems like good practice.

I also made changes related to general stability, not explicitly to the E2E tests:

  • Added a pm2-connection.lock lockfile to ensure that multiple site start commands triggered in quick sequence are still able to properly connect to the pm2 daemon. Previously, if multiple sites had an autoStart config, only one site would start when Studio started. The other sites would stall indefinitely.
  • Force all pm2 processes (including the daemon) to quit if there's a pending update. This allows the auto-updater to overwrite files that might otherwise be locked on Windows (since they're currently in use).
  • Change the pm2 patch to clarify that the pm2.disconnect method takes a callback, and make all disconnect calls async.

Testing Instructions

CI should pass.

Pre-merge Checklist

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

@fredrikekelund fredrikekelund self-assigned this Dec 19, 2025
Comment on lines +129 to +130

process.on( 'SIGINT', disconnect );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The studio site list --watch command would previously not interrupt in response to Ctrl+C

@fredrikekelund
Copy link
Contributor Author

OK, after one more round of changes, the tests are now consistently green, and I've slimmed down the diff as much as possible.

Comment on lines -15 to +22
logger.reportStart( LoggerAction.LOAD_SITES, __( 'Loading site…' ) );
const site = await getSiteByFolder( sitePath );
logger.reportSuccess( __( 'Site loaded' ) );

logger.reportStart( LoggerAction.START_DAEMON, __( 'Starting process daemon…' ) );
await connect();
logger.reportSuccess( __( 'Process daemon started' ) );

logger.reportStart( LoggerAction.LOAD_SITES, __( 'Loading site…' ) );
const site = await getSiteByFolder( sitePath );
logger.reportSuccess( __( 'Site loaded' ) );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the connect call to the top of this function to fix a bug where triggering many site start commands in quick succession would cause only one site to start (the others would hang indefinitely).

Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Amazing work not only on making E2E tests pass but ensuring the solution is robust and solid.

@fredrikekelund fredrikekelund merged commit e592d2a into dev/studio-cli-i2 Jan 14, 2026
4 checks passed
@fredrikekelund fredrikekelund deleted the f26d/fix-e2e-tests-windows branch January 14, 2026 13:29
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.

3 participants