Can't get any output from proc_open in PHP

I'm trying to run Chrome in headless mode in PHP because I'd like to get some info about block height from HTML generated in PHP.

So, I'm using REPL (Read-Eval Print Loop) mode (as seen in the doc: )

My idea is to pop a Chrome headless process with my HTML file, ask him some info about blocks in the DOM and exiting.

So, I've proceeded this way:

$chromeIO = array(
        0 => array("pipe", "r"),
        1 => array("pipe", "w"),
        2 => array("file", "/tmp/error-output.txt", "a")
    );$target = 'chromium --headless --disable-gpu --repl file:///tmp/test.html'; // For debug, hardcoded file
    $this->chromeInstance = proc_open($target, $chromeIO, $this->pipes);
    fwrite($this->pipes[0], 'document.getElementsByTagName(\'body\')[0].offsetHeight'."\n");
    $content = stream_get_contents($this->pipes[1]);

But this code is hanging on the stream_get_contents line. If I add stream_set_blocking to false on my pipes, code doesn't block, but I got no return from $content. I've tried with fread and anything I could find but I can't get anything from the process.

In the error log, I only got this line: [0113/] Type a Javascript expression to evaluate or "quit" to exit., which is what you get when you launch Chrome in headless mode. So, everything looks fine to me.

But why can't I get any output ? If I run this command manually, it works perfectly.

I've also tried to output stdout to a file but in this case, I get this result >>> {"result":{"type":"undefined"}} repeated at least one million times.

It's like my commande is never executed… That's strange.

What am I doing wrong ?