-
Notifications
You must be signed in to change notification settings - Fork 273
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
Run JSPI in Node.js #1873
Comments
The experimental flags work in Node.js. It's just Node won't display new WebAssembly.Suspender();
new WebAssembly.Function(); But the ones from the new JSPI API fail: new WebAssembly.Suspending();
WebAssembly.promising() Node.js v22 LTS is stuck with the current v8 release:
This means we can either wait for Node.js v23 (scheduled for release on Oct 15) and hope it will ship the latest v8 version, or we can build JSPI binaries for Node.js using the older API. I'd say let's wait for Node.js to catch up. Any code we write to support the older API will take time to write and we'll have to undo it in a few months anyway. Patience is the key. |
I just confirmed Node.js v23 nightly supports the latest JSPI API! |
I just triggered the unit tests using this command and a lot of them passed 🎉 $ ~/Downloads/node-v23.0.0-nightly2024100909d10b50dc-darwin-x64/bin/node --experimental-wasm-jspi --experimental-wasm-stack-switching --expose-gc node_modules/nx/bin/nx run php-wasm-node:test There were some failures, though. Both ones that we can safely ignore, such as
And ones we'll need to look into:
|
Nice work here!
It seems unlikely that this failure is due to a long-running test, but maybe it would be worth increasing the timeout to check. See: |
#1876 should do the trick |
Fixed in #1876. The next released packages will support JSPI. |
Gets `@php-wasm/node` and all the other CLI packages to load the .wasm binaries from the correct path after #1867 introduced JSPI and #1873 made it pass all the tests in Node.js ## Technical details In the repo, php.js files are stored in php_wasm/node/jspi or php_wasm/node/asyncify. They start with a line like this: const dependencyFilename = __dirname + '/8_0_30/php_8_0.wasm'; After the build, the contents are concatenated into a single file, which breaks the dependencyFilename variable. This plugin corrects that by replacing __dirname with the correct value such as 'jspi' or 'asyncify'. The implementation is naive and assumes the substrings __dirname is only used as a variable, are not a part of any other name, and is not seen in any string literals. ## Test plan Build the production packages with `nx build php-wasm-node` and run the PHP CLI package to confirm it doesn't crash. I couldn't get npm link to work so I created a `dist/packages/php-wasm/node_modules/@php-wasm` directory and linked all the built packages there with `ln -s`.
…1877) Gets `@php-wasm/node` and all the other CLI packages to load the .wasm binaries from the correct path after #1867 introduced JSPI and #1873 made it pass all the tests in Node.js ## Technical details In the repo, php.js files are stored in php_wasm/node/jspi or php_wasm/node/asyncify. They start with a line like this: const dependencyFilename = __dirname + '/8_0_30/php_8_0.wasm'; After the build, the contents are concatenated into a single file, which breaks the dependencyFilename variable. This plugin corrects that by replacing __dirname with the correct value such as 'jspi' or 'asyncify'. The implementation is naive and assumes the substrings __dirname is only used as a variable, are not a part of any other name, and is not seen in any string literals. ## Test plan Build the production packages with `nx build php-wasm-node` and run the PHP CLI package to confirm it doesn't crash. I couldn't get npm link to work so I created a `dist/packages/php-wasm/node_modules/@php-wasm` directory and linked all the built packages there with `ln -s`.
The latest ~/Downloads/node-v23.0.0-nightly2024100909d10b50dc-darwin-x64/bin/node --experimental-wasm-jspi --experimental-wasm-stack-switching ./cli server There isn't yet an easy way of checking which build are we running. It would be cool to add a line to phpinfo(). cc @bgrgicak I'm really curious how many more plugins would now insta.. |
@wojtekn this would make Studio much more stable with MySQL - no more WASM crashes |
I need to spend some time making the test runner scalable and adding support for different tests. |
JSPI landed in
trunk
in both@php-wasm/web
and@php-wasm/node
packages. I couldn't figure out how to enable JSPI support in Node.js, though. It worked back in #1339 with the following CLI flags, but it doesn't work anymore:Could that be related to the new JSPI API in v8? That would be weird, though, because
WebAssembly
in either case theWebAssembly
object doesn't expose any JSPI-related keys – new or old. There's noSuspending
,Function
,Suspender
, and anything else:Once we can running the JSPI build in the CLI, we'll be able to check how many new plugins can be installed compared to the Asyncify build:
https://github.com/bgrgicak/playground-tester/
cc @bgrgicak @brandonpayton
The text was updated successfully, but these errors were encountered: