-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP: Handle request errors in PHPRequestHandler, return response code…
… 500 (#1249) Moves the handling of PHP fatal errors from a service worker message listener, where only the in-browser Playground can use it, to `PHPRequestHandler`, that allows all the Playground apps like Studio and `wp-now` to benefit. In addition, this PR ensures that HTTP 500 Internal Server Error is returned if PHP exits with a non-zero code. This is required because PHP itself seems to happily return HTTP 200 in those cases. ## What problem is it solving? Studio app is showing error logs and is hung under certain scenarios. This pr fixes that. ## How is the problem addressed? By catching the error, and returning the error response. ## Testing Instructions The easiest way I found to test it was via Studio, where the problem appeared originally. - Clone the Studio app - Change `package.json` and replace `@php-wasm` references with the following: ``` "@php-wasm/node": "file:../wordpress-playground/dist/packages/php-wasm/node", "@php-wasm/util": "file:../wordpress-playground/dist/packages/php-wasm/util", "@php-wasm/node-polyfills": "file:../wordpress-playground/dist/packages/php-wasm/node-polyfills", "@php-wasm/universal": "file:../wordpress-playground/dist/packages/php-wasm/universal", ``` - Change `webpack.main.config.ts` and replace the externals object with the following: ``` externals: { '@php-wasm/node': '@php-wasm/node', '@php-wasm/universal': '@php-wasm/universal', '@php-wasm/util': '@php-wasm/util', '@php-wasm/node-polyfills': '@php-wasm/node-polyfills', }, ``` - Clone this pr. - Run `npm i` - Run `npx nx reset && npm run build` - Back to the Studio repo, run `npm i` - Create a new site. - Install `WooCommerce` - Reload the `wp-admin` - Ensure that the dashboard is showing as expected instead of hanging. ### Run tests manually 1 From the root of the project run: `npx --expose-gc nx run php-wasm-node:test --testFile ./packages/php-wasm/node/src/test/php-request-handler.spec.ts --skipNxCache` --------- Co-authored-by: Adam Zielinski <adam@adamziel.com>
- Loading branch information
Showing
5 changed files
with
104 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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