hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.27k stars 438 forks source link

`WaitTaskTimeoutException` regression in v10.0.0 #2205

Open danports opened 1 year ago

danports commented 1 year ago

Since upgrading to v10.0.0 from v9.1.0, I'm seeing a much higher rate of WaitTaskTimeoutExceptions being thrown. It seems that frequently (but not always), calls to WaitForSelectorAsync are timing out despite the fact that the selector passed is actually available in the page. Downgrading back to v9.1.0 fixed the problem, so I suspect this is a regression related to #2190.

kblok commented 1 year ago

That's unfortunate. Do you have any piece of code to help me reproduce the issue?

danports commented 1 year ago

This has proven more difficult to reproduce than I expected. I suspect that it may have something to do with the environment where I'm running PuppeteerSharp (Ubuntu-based containers), since I haven't yet been able to reproduce this issue under Windows. I tried upgrading to v10.0.0 again today just to see if I imagined the problem and it immediately recurred, so it's definitely reproducible, but I'm not yet sure which conditions are necessary to reproduce it.

danports commented 1 year ago

I think this issue is related to awaiting a selector before DOM content has fully loaded, as in:

_ = page.GoToAsync("https://www.example.com/", new NavigationOptions { Timeout = 0, WaitUntil = new[] { WaitUntilNavigation.DOMContentLoaded } });
await page.WaitForSelectorAsync("<some selector>");

This usage pattern is probably a bit unusual but can be useful when DOM content never fully loads, e.g. due to anti-bot systems.