Open divinity76 opened 9 months ago
Thanks for the report. I'm not going to be able to look into this issue (I say this to set expectations), but if you'd like to, that's fine.
I don't have access to a windows machine at this moment, but I'll try to take a look at it in the next week.
Still happens sporadically on Windows 11, PHP 8.3.6, chrome-php/chrome 1.11.0, forcing me to make hacks like
- $loginError = $page->evaluate('document.querySelector("[role=alert]")?.textContent')->getReturnValue();
+ try {
+ $loginError = $page->evaluate('document.querySelector("[role=alert]")?.textContent')->getReturnValue();
+ } catch(\Throwable $ex){
+ sleep(1);
+ $loginError = $page->evaluate('document.querySelector("[role=alert]")?.textContent')->getReturnValue();
+ }
For Windows compatibility:
document.querySelector("[role=alert]")?.textContent
Sometimes timeouts (getReturnValue() crashing on timeout, but only on Windows)
Theorizing that it might be a timing issue where chrome-php sends the JavaScript to chrome before setting up the listener for the result, and depending on how the OS thread scheduler work, the result might be sent before the listener for the result is set up? Maybe? (In which case a reordering of setting up listener and sending the JavaScript should fix it)
Have not found a good way to reproduce it, but basically, with valid login credentials, on Windows (but not Linux), there's like a 50% chance of the line
throwing a
in this code..
and I've run the same code many times on Ubuntu, it does not happen in Ubuntu at all, it only happens on Windows.. Check this shell log, when you get
int(123)
it didn't happen:it's like a 50% chance of timing out on that "123" eval!
any idea why
$page->evaluate('123')->getReturnValue();
would throw like this? but only on Windows?Can reproduce on: PHP 8.3.0, chrome-php/chrome 1.10.0, Windows 10 x64, Chrome Version 120.0.6099.71 (Official Build) (64-bit)
Can not reproduce on: PHP 8.2.13, chrome-php/chrome 1.10.0, Ubuntu Linux 22.04 x64, Chromium Version 120.0.6099.71 (Official Build) snap (64-bit)
Both are running on a very fast system, definitely should not be a CPU issue (AMD Ryzen 9 7950x, 64GB RAM), should not be a network connection issue either, running on a shared office 1gbps internet connection, with cable.. i'm certain it's not a network issue. .