-
Notifications
You must be signed in to change notification settings - Fork 270
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
Explore curl support #1133
Explore curl support #1133
Conversation
|
NTML and NTLM_WP are both set to no in PHP info. I don't think that this is caused by using This message is documented in CURL. We could try to disable |
Disabling AsynchDNS resolved the thread failed to start error. Now the test request times-out and from the sound of my fans, it keeps doing something in the background. I haven't debugged it. |
The verbose output has some insights:
I see that we use TCP_NODELAY in PHP-WASM, but I don't know where is this coming from: TCP_NODELAY: Protocol not available |
|
I need to wrap up now, this is what I found today:
|
I attempted another approach on my end by trying to run
I still get the same error of course :
So I tried to make a comparison with built-in
when
Additionally, the following information is present in
I'm not sure if this information could be helpful, but it's something I noticed." |
Thank you @mho22! I have an hour now and can take a look at it. |
Good sources of information |
Fixed the link https://github.com/curl/curl/blob/master/configure.ac |
It looks like this will take some effort to find the correct combination of flags and link all required libraries. |
@mho22 feel free to take over, I'm not sure if I will have time to work more on this. |
I only had the |
I don't know why it produces an error here but :
returns :
duplicate symbol errors prevent the script to successfully end. |
I think that's fine, at that point
It would be useful to have a comment in place to document that behavior. |
@adamziel Ok thank you. Could it be possible that
I suspect I currently don't have the tools to investigate this. But I should try :
This assumes that the Dockerfile script runs correctly. We can consider having
And in fact if we display
I only displayed the differences between the two curls. But what next ? How can I be sure the problem comes from |
@@ -29,6 +29,8 @@ RUN CPPFLAGS="-I/root/lib/include " \ | |||
--enable-https \ | |||
--enable-http \ | |||
--disable-pthreads \ | |||
--disable-threaded-resolver | |||
--enable-websockets \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed for v1
I forgot to push it yesterday. This commit adds zlib. 0c84fd1 |
@bgrgicakI Thanks ! I found out two days ago it was
|
@mho22 I added your code and found it 's actually getting responses 🎉 I pushed your changes and updated the request URL so that we can see the next error. Now when I run it, there is an Asyncify error. Here are the missing functions: I tried adding these functions to the Docker file but it can't rebuild because of |
@bgrgicak I added these methods in
Now I get an error linked with
Asyncify.state returns |
I pushed your changes and rebuilt 8.0. This is the error I get in the browser.
|
Unrelated, I tried compiling Node to add a test and it can't compile PHP<=7.3 |
@bgrgicak @adamziel I tried to run this with
Each element of this list has its name in the When running
I don't know if this can help ? This is the only way I found to have a bit of informations about this. But I am stuck here. Some methods are just invisible. |
@bgrgicak You were right. Your new error was the next one. Mine made me lose a lot of time I suppose. To have new information about the next error, I had to remove that
Now the error indicates that there is an invalid websocket when calling When we tested on
Now, when we call the
With the error :
@adamziel This looks like something promising right ? |
@mho22 apologies for the radio silence, I was quite swamped lately. Thank you for persevering – this looks very promising indeed! Now it gets interesting. The
A few ideas:
A few console.log statements in |
@adamziel You were right, this comes from
I I should continue my investigation, but if you have any other clues, I'm open to following them. I found out that the This is a normal Stream : This is our Stream fd 19 : I also found out there is only one |
Oh,
I'm not sure what is the relevance of |
@adamziel Fantastic ! I only commented the line I don't know where I should short-cicuit this and return 1 in this case. There is something missing here concerning certificates but I think we should add a CURLOPT linked with certificates maybe : |
In To solve the certificate error, adjust the top-level domain in base-php where a fake temporary SSL certificate is generated. |
I hoped it worked fine but I modified
As you can see CN is no more I also added a I decided to try out something else and add two other curl_opts:
But it resulted with a CORS error. |
@mho22 CORS error could be the expected outcome here. Try https://downloads.wordpress.org/plugin/hello-dolly.1.7.3.zip – it should have the correct CORS headers. |
@adamziel I am sorry but I am a little bit confused here. Do I need to add the Sorry for this. I am a little bit lost with SSL. |
@mho I just meant use CURL to request |
@adamziel I replaced
Great ! Even if there is a The CORS error appears. I decide to add these lines in the
And the header appears in the request : But of course, CORS is still there, what do you think should be the next step here ? |
@mho22 I'm afraid this is as far as we can go. CURL or not, ultimately all the traffic goes through fetch() which is limited by the CORS rules. To access arbitrary URLs, we'd need to set up a server-side WebSockets<->TCP proxy like the one wp-now uses. Or open up "plugin-proxy.php" to all requests and methods. |
@adamziel We should also try to make this work in any PHP versions on |
Great work @mho22 🚀 |
Let's start with As for next steps here, I suggest:
And then let's get it merged! Thank you for your fantastic work @mho22! :) |
@mho22 any updates on this one? It would be really cool to support curl. |
@adamziel Sorry for the silent days. I have to focus on other tasks on my side. Anyways, I cannot figure out why I still have
Here is the list of methods called with the
Every line is in the I am currently trying to run in 'php-wasm/wordpress-playground' : in 'php-wasm/test' file
in 'php-wasm/test' : Where my
You probably have a better way to try to make My
I should probably create a new branch a start from scratch and follow the things we added progressively here. |
Closing in favor of #1273 that ships a working curl build |
Ships the Node.js version of PHP built with `--with-libcurl` option to support the curl extension. It also changes two nuances in the overall PHP build process: * It replaces the `select(2)` function using `-Wl,--wrap=select` emcc option instead of patching PHP source code – this enables supporting asynchronous `select(2)` in curl without additional patches. * Brings the `__wrap_select` implementation more in line with `select(2)`, add support for `POLLERR`. * Adds support for polling file descriptors that represent neither child processes nor streams in `poll(2)` – that's because `libcurl` polls `/dev/urandom`. Builds on top of and supersedes #1133 ## Debugging Asyncify problems The [typical way of resolving Asyncify crashes](https://wordpress.github.io/wordpress-playground/architecture/wasm-asyncify/) didn't work during the work on this PR. Functions didn't come up in the error messages and even raw stack traces. The reasons are unclear. [The JSPI build of PHP](#1339) was more helpful as it enabled logging the current stack trace in all the asynchronous calls, which quickly revealed all the missing `ASYNCIFY_ONLY` functions. This is the way to debug any future issues until we fully migrate to JSPI. ## Testing Instructions Confirm the CI checks pass. This PR ships a few new tests specifically targeting networking with curl. ## Related resources * #85 * #1093 --------- Co-authored-by: Adam Zieliński <adam@adamziel.com> Co-authored-by: MHO <yannick@chillpills.io>
What is this PR doing?
Explores building PHP with libcurl support
CURL builds, PHP builds with the
--with-curl
flag,curl_init()
etc run as expected.However, running the following PHP snippet fails:
Reproduction link: http://localhost:5400/website-server/?php=8.0&wp=6.4&storage=none&php-extension-bundle=kitchen-sink&url=/test-curl.php
Curl likely runs
fork()
internally, similarly to PHP'sproc_open()
. Getting it to work in Playground will require patchingcurl
source code to remove thatfork()
call and, likely, replace it with a JavaScript function call – similarly to the0proc_open()
patch.To rebuild curl, run:
cc @mho22 – I spent an hour here just to get to the first roadblock. I won't be able to spend more time here for now – you're more than welcome to take over. I'd love to see a functional CURL extension!
Related resources