Skip to content

Fix Studio site crashing when rotatePHPRuntime was executed - #1019

Merged
sejas merged 2 commits into
trunkfrom
update/sutdio-rotate-php-runtime
Mar 6, 2025
Merged

Fix Studio site crashing when rotatePHPRuntime was executed#1019
sejas merged 2 commits into
trunkfrom
update/sutdio-rotate-php-runtime

Conversation

@sejas

@sejas sejas commented Mar 6, 2025

Copy link
Copy Markdown
Member

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

@ivan-ottinger ivan-ottinger 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.

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

sejas commented Mar 6, 2025

Copy link
Copy Markdown
Member Author

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 Mar 6, 2025
@sejas
sejas merged commit 4a6e5e8 into trunk Mar 6, 2025
@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

2 participants