Skip to content
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

waitForPredicatePageFunction doesn't respect timeout equal to 0 #2540

Closed
Kai-Dominik opened this issue May 13, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@Kai-Dominik
Copy link

commented May 13, 2018

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.4.0
  • Platform / OS version: macOS
  • URLs (if applicable): -
  • Node.js version: v8.9.1

What steps will reproduce the problem?

I know that I could use page.waitForSelector instead of following the snippet, but this snippet helps me right now to show the problem.

const querySelector = () => {
    return `document.querySelector('${selector}') !== null`;
};
const result = await this.page.waitForFunction(querySelector(), {
    polling: 50,
    timeout: 0,
});

What is the expected result?
I would expect that the following function would wait till the element with the given selector is present and then resolves.

What happens instead?
The method waitForPredicatePageFunction in the WaitTask class does not respect timeout of 0, which should disable the timeout.
So the function resolves immediately without running even once the predicate function.

See here

The referenced line needs to be changed from

setTimeout(() => timedOut = true, timeout);

to

if (timeout) {
    setTimeout(() => timedOut = true, timeout);
}

@aslushnikov aslushnikov added the bug label May 17, 2018

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue May 17, 2018

fix(Page): respect timeout 0 in page.waitForFunction
The in-page task should not set timeout when timeout is 0.

Fixes GoogleChrome#2540.

aslushnikov added a commit that referenced this issue May 25, 2018

fix(page): respect timeout 0 in page.waitForFunction (#2563)
The in-page task should not set timeout when timeout is 0.

Fixes #2540.

LarenDorr added a commit to LarenDorr/puppeteer that referenced this issue Mar 19, 2019

fix(page): respect timeout 0 in page.waitForFunction (GoogleChrome#2563)
The in-page task should not set timeout when timeout is 0.

Fixes GoogleChrome#2540.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.