Created
July 5, 2025 21:32
-
-
Save adamziel/9a3cfb83f4a0ebd78e4f335e69f50087 to your computer and use it in GitHub Desktop.
Debugging Asyncify functions in Playground
This file contains hidden or 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
| rm out.txt | |
| PHP=7.4 node --stack-trace-limit=100 --loader=./packages/meta/src/node-es-module-loader/loader.mts ./packages/php-wasm/cli/src/main.ts test.php &> out.txt | |
| cat out.txt | bun packages/meta/bin/verify-asyncify-functions.ts |
This file contains hidden or 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
| import fs from 'fs'; | |
| import path from 'path'; | |
| const DockerfilePath = path.resolve( | |
| __dirname, | |
| '../../../packages/php-wasm/compile/php/Dockerfile' | |
| ); | |
| function addAsyncifyFunctionsToDockerfile(functions: string[]) { | |
| const Dockerfile = fs.readFileSync(DockerfilePath, 'utf8') + ''; | |
| const cleanedUpFunctions = functions.map((candidate) => | |
| candidate | |
| .trim() | |
| .replace(/^"|^\s*\* php\.wasm\.|"$/g, '') | |
| .replace('byn$fpcast-emu$', '') | |
| ); | |
| console.log('Looking for these functions in the Dockerfile:'); | |
| console.log(cleanedUpFunctions); | |
| const DockerfileSubset = Dockerfile.split("ASYNCIFY_ONLY_UNPREFIXED")[1]; | |
| const missingCandidates = cleanedUpFunctions.filter( | |
| (candidate) => !DockerfileSubset.includes(`"${candidate}"`) | |
| ); | |
| if (missingCandidates.length) { | |
| console.log('Missing functions:'); | |
| console.log(missingCandidates.join('\n')); | |
| } else { | |
| console.log('All functions are present in the Dockerfile.'); | |
| } | |
| } | |
| let input = ''; | |
| process.stdin.setEncoding('utf8'); | |
| process.stdin.on('data', (chunk) => { | |
| input += chunk; | |
| }); | |
| process.stdin.on('end', () => { | |
| const lines = input | |
| .split('\n') | |
| .map((line) => line.trim()) | |
| // Detect stacktrace lines related to php.wasm | |
| .filter((line) => line.length > 0) | |
| .filter((line) => line.includes("at ") && line.includes("wasm:")) | |
| .map((line) => line.split("php.wasm.")[1].split(" ")[0].trim()); | |
| ; | |
| addAsyncifyFunctionsToDockerfile(lines); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment