-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Exit http server on php exit (#1714)
## Motivation for the change, related issues Calling the `php.exit` caused a hanging connection. This had affect in tests, and leaving open connections around. ## Implementation details Attach the HTTP server that we spawn to handle websocket connections to the PHP instance. When we call `.exit` we use the attached instance to close the connections. ## Testing Instructions (or ideally a Blueprint) 1. Create a project with the following test code: ```import { getPHPLoaderModule, withNetworking } from '@php-wasm/node'; import { PHP, __private__dont__use, loadPHPRuntime } from '@php-wasm/universal'; const isWindows = process.platform === 'win32'; const dostuff = async function() { const id = await loadPHPRuntime( await getPHPLoaderModule('8.3'), await withNetworking({}) ); const php = new PHP(id); const privateSymbol = Object.getOwnPropertySymbols(php) .find(sym => String(sym).includes('__private__dont__use')); const result = await php.run({ code: `<?php echo "HI!"; `} ); console.log(result.text); php.exit(); } dostuff().catch(console.error); ``` 2. Build `php-wasm/node` and `php-wasm/universal` ``` npx nx run php-wasm-universal:build npx nx run php-wasm-node:build ``` 4. Cd into `/dist` php-wasm folder and run `npm link` 5. Go to the project and run `npm link @php-wasm/node` and `npm link @php-wam/universal` 6. Navigate inside node module, in each package and run `npm install` 7. Run the script you have created 8. Ensure that exits successfully
- Loading branch information
Showing
4 changed files
with
37 additions
and
2 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