Serve a PHP error page and auto-recover when a site fails to start#4246
Draft
gcsecsey wants to merge 3 commits into
Draft
Serve a PHP error page and auto-recover when a site fails to start#4246gcsecsey wants to merge 3 commits into
gcsecsey wants to merge 3 commits into
Conversation
…' into gcsecsey/stu-1370-php-error-recovery # Conflicts: # apps/studio/src/ipc-handlers.ts
…php-error-recovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
runCLI()throws instead of callingprocess.exit(). Review and merge Bump Playground to 3.1.45 #4230 first.Important
Because this branch includes the 3.1.45 bump, it carries the same npm cooldown as #4230: CI cannot install 3.1.45 until 2026-07-18 (around 04:13 UTC), and local installs need
npm install --min-release-age=0until then.How AI was used in this PR
I used Claude to port the PHP-error recovery from an earlier branch onto current trunk (reconciling a file rename and the evolved
ipc-handlersstart flow), wire it into the start and stop handlers, and add unit tests for the error classification and parsing. I reviewed the logic and verified typecheck, build, and the tests myself. The end-to-end UX still needs manual verification since it cannot be exercised headless.Proposed Changes
STU-1370: when a site has a fatal PHP error (for example in a theme or a mu-plugin), starting it should not just fail. The site should come up and show the error, the way the native-PHP runtime already does.
For the Playground (WASM) runtime this cannot be done the native way. Playground warm-boots WordPress at startup, so a fatal aborts the boot and the server never comes up, which means there is no live WordPress to render its own error page. This PR adds a Studio-side recovery that fills that gap:
.phpfile changes, so fixing the error auto-recovers the site.Testing Instructions
Because this branch includes 3.1.45 (still in the npm cooldown), install with the cooldown bypassed. A plain
npm installworks from 2026-07-18 onward.npm install --min-release-age=0npm startwp-content/mu-plugins/fatal.phpin the site folder containing<?php trigger_error( 'Intentional fatal for testing', E_USER_ERROR );, then start the site. Expected: the site comes up and serves an error page showing the PHP error, instead of a failure modal.fatal.php. Expected: the file watcher retries and the real site loads automatically..phpfile and reload the site in the browser. Expected: WordPress's own error page is served by the warm server.Known issues (draft / WIP)
EADDRINUSEon a subsequent start. Fix in progress: tear down recovery (releasing the port) before any start, and stop faking the main-process running state.Pre-merge Checklist