Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Studio site crashing when rotatePHPRuntime was executed #1019

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

sejas
Copy link
Member

@sejas sejas commented Mar 6, 2025

Related issues

Proposed Changes

  • Remove default Hello wp-now "virtual" index.php
  • Avoids remounting directories, which prevents PHP runtime crashes during rotation.

Why?
It seems in the past the rotatePHPRuntime was starting a fresh Playground that needed mounting the directories, and that's not the case anymore.

Testing Instructions

  • Apply this diff to reduce the number of requests that produces a PHP runtime rotation.
diff --git a/vendor/wp-now/src/wp-now.ts b/vendor/wp-now/src/wp-now.ts
index b3e61cd1..0c0b3235 100644
--- a/vendor/wp-now/src/wp-now.ts
+++ b/vendor/wp-now/src/wp-now.ts
@@ -135,7 +135,7 @@ export default async function startWPNow(
 			await prepareWordPress( php, options );
 			return runtimeId;
 		},
-		maxRequests: 400,
+		maxRequests: 10,
 	} );
 
 	return {

  • Run npm start
  • Start a site
  • Access wp-admin, index, and other pages/posts multiple times
  • Observe the message Recreating and rotating PHP runtime every ~10 PHP requests.

I've also observed that the message Stopped watching for file changes but I confirm that the file changes are still working. I edited the main index.php and I saw the changes applied correctly in the browser.

Pre-merge Checklist

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

@sejas sejas self-assigned this Mar 6, 2025
@sejas sejas requested a review from a team March 6, 2025 15:49
Copy link
Contributor

@ivan-ottinger ivan-ottinger left a comment

Choose a reason for hiding this comment

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

After applying the proposed change, I cannot reproduce the issue anymore. 👌🏼 Nice! The correct index.php is preserved. Great investigation!

One thing to consider is that the sites that already have their index.php replaced with the default one won't get fixed automatically.

If this is not a widespread issue, we could let the affected users know how to get their index.php file back, or we could consider addressing that in the PR as well.

@sejas
Copy link
Member Author

sejas commented Mar 6, 2025

One thing to consider is that the sites that already have their index.php replaced with the default one won't get fixed automatically.

If this is not a widespread issue, we could let the affected users know how to get their index.php file back, or we could consider addressing that in the PR as well.

Good point. I think the safest approach is letting the user know and suggesting them to update the index.php file manually.

@ivan-ottinger ivan-ottinger changed the title Fix Sutdio site crashing when rotatePHPRuntime was executed Fix Studio site crashing when rotatePHPRuntime was executed Mar 6, 2025
@sejas sejas merged commit 4a6e5e8 into trunk Mar 6, 2025
9 of 10 checks passed
@sejas sejas deleted the update/sutdio-rotate-php-runtime branch March 6, 2025 16:12
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.

2 participants