-
Notifications
You must be signed in to change notification settings - Fork 268
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
PHP: Handle request errors in PHPRequestHandler, return response code 500 #1249
PHP: Handle request errors in PHPRequestHandler, return response code 500 #1249
Conversation
NOTE: |
This will work as expected once #1252 lands and return new PHPResponse(
exitCode === 0 ? httpStatusCode : 500, |
Ensures PHP returns the correct exit code after each request. Without this PR, hitting an exit code 255 once means PHP will continue returning it indefinitely. Related to #1249 ## Testing instructions Confirm the unit tests pass (they won't until all PHP versions are rebuilt and shipped with this PR) cc @kozer --------- Co-authored-by: Brandon Payton <brandon@happycode.net>
Updated the PR , and added some tests |
…from the service worker message listener
What is this PR doing?
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 andwp-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.
package.json
and replace@php-wasm
references with the following:webpack.main.config.ts
and replace the externals object with the following:npm i
npx nx reset && npm run build
npm i
WooCommerce
wp-admin
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