-
Notifications
You must be signed in to change notification settings - Fork 210
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
Calls proc_open two times in a row #1012
Calls proc_open two times in a row #1012
Conversation
@adamziel, I'm not sure if adding the FYI the first commit in this PR is a failing test. |
Thank you for reporting and working on the fix! I investigated a bit and found that we miss out on the second cp = await PHPWASM.spawnProcess(cmdstr, argsArray); The timeline seems to be as follows:
I'm not sure why the problem only happens on a second call – perhaps some internal value is already initialized after the first In any case, this seems to solve the issue: - cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
+ if (cp instanceof Promise) {
+ cp = await cp;
+ } The solution proposed in this PR, that is waiting for |
@adamziel I am on it! There are two |
Both sounds good! |
@adamziel Everything appears to be in order. 🎉 Thank you for your time. |
Thank you! |
What is this PR doing?
It should correct the problem of
proc_open()
freezing after called one time. The freeze is due tophpwasm-emscripten-library.js
line 424await new Promise...
.What problem is it solving?
Calling
proc_open
two times in a row will lead to a freeze due to this part of the code in thephpwasm-emscripten-library.js
file :If
spawn
has already been called, it freezes indefinitely. In the test case, calling two timesproc_open
in a row will lead to that freeze. The solution would be to add another event listener beingcp.on('exit', resolve)
. Ifspawn
has already been called, the next events should logically bestdout
andexit
.Testing Instructions
node --expose-gc node_modules/nx/bin/nx run php-wasm-node:test
packages/php-wasm/node/src/test
on line 500