Asyncify: Test all network functions and all ways to trigger a function call #273
Labels
[Aspect] Asyncify
[Feature] PHP.wasm
[Priority] Low
[Type] Bug
An existing feature does not function as intended
[Type] Enhancement
New feature or request
Milestone
Description
As explained in #251 and #253, all PHP code paths leading to an asynchronous network call must be listed in php-wasm/compile/Dockerfile. In the longer term, we'll move from Asyncify to JSPI API that has a much simpler configuration, but for now we'll need to maintain the
ASYNCIFY_ONLY
list.Finding them manually would be tedious or impossible, so #253 introduced a test suite that detects and auto-adds any missing code paths. That test suite should cover the following two concepts as exhaustively as possible:
Network functions
PHP functions directly responsible for triggering a network call like
file_get_contents
,fsockopen
,mysql_connect
should be listed here:wordpress-playground/packages/php-wasm/node/src/test/php-asyncify.spec.ts
Lines 32 to 54 in 98a9d8d
A bunch of them already is, but there's also a TODO comment listing the missing ones
Function calls
Different ways of calling the network functions like a direct function call, method call, reflections API are covered by specific test cases here:
wordpress-playground/packages/php-wasm/node/src/test/php-asyncify.spec.ts
Lines 63 to 77 in 98a9d8d
The initial list is nice, but we should also cover destructors, shutdown functions, serializable interface, and anything else you can think of.
Rebuilding PHP
After adding a test case, run
If all the tests are green, good. If they're not, you may auto-fix the Dockerfile and rebuild PHP using this command:
This takes some time so you may want to add all your test cases first and then run
fix-asyncify
just once at the end. Once it completes, all your new tests should pass.The text was updated successfully, but these errors were encountered: