question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: "Soft" timeout when using WaitFor<x>

See original GitHub issue

While discussing another issue with @kblok, I stumbled upon another small hiccup which lead me to think about this feature request.

The initial problem is that I had timeout errors while trying to generate a pdf. I finally found the culprit, I was using page.WaitForSelector in which I specified a selector that is was always present on page depending on some conditions.

To make a long explanation “relatively shorter”:

  1. I am generating a report in which I do generate trending graphics, but only when enough data is present to make it useful.
  2. As this can be a relatively long process (couple seconds), I had to find a way to wait until the graphics are generated before doing the pdf conversion, otherwise I would be left with partial reports.
  3. I decided to use the page.WaitForSelector which is waiting on an element with a css class that is given to it once all graphics have completed their initialization.
  4. The problem was that if not enough data was provided, I was skipping the graphics initialization (and consequently the css flag was never added to the element, resulting in the timeout)

I would want to know if there is a way to use WaitForSelector, but instead of having a hard timeout in which an exception is thrown, it would be really nice if we could have an option to set a “soft timeout” which would simply block the generation process while waiting for the selector and after the specified timeout, simply go on and perform the conversion even if the condition was not respected.

I think that could add a certain flexibility to the usage of the page.WaitFor<x> for cases when the desired outcome would be, simply said “Wait until condition is respected, otherwise simply go on and do the conversion/perform the remaining script steps”, which is not possible at the moment with Playwright from my understanding.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kblokcommented, Oct 14, 2020

@arjunattam we talked with @lvmajor about that here https://github.com/microsoft/playwright-sharp/issues/942#issuecomment-708651438 .

That’s a possible solution. The thing is that an exception in .NET is “expensive”. There is a good practice that says that you shouldn’t use try-catch to control the flow.

I’m wondering if this could be a feature in PW, or something with can do on PW# to avoid the exceptions…

1reaction
lvmajorcommented, Oct 14, 2020

Lol you beat me to it a couple seconds ahah

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: "Soft" timeout when using WaitFor<x> · ...
The initial problem is that I had timeout errors while trying to generate a pdf. I finally found the culprit, I was using...
Read more >
React Testing Library's waitFor not working
I found the answer here: React Testing Library - using 'await wait()' ... The default timeout is 1000ms which will keep you under...
Read more >
Avoiding hard waits in Playwright and Puppeteer
We try to solve this issue with a hard wait, like Puppeteer's page.waitFor(timeout) . This could looks something like the following:.
Read more >
Bugs fixed in each 19.0.0.0.0 Release Update and ...
This document lists the non-security important bugs( NOT ALL bug fixes) fixed in each 19.0.0.0.0 Release Update and Release Update ...
Read more >
Troubleshoot IP Phone Unregistration - A Case Study
The SCCP phones should make a TCP connection with the Cisco ... the phone will wait for X seconds before it detects the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found