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

page.waitForSelector timeout & ExecutionContext.evaluateHandle hanging #4072

Closed
nfwyst opened this issue Feb 26, 2019 · 23 comments
Closed

page.waitForSelector timeout & ExecutionContext.evaluateHandle hanging #4072

nfwyst opened this issue Feb 26, 2019 · 23 comments
Labels
bug chromium Issues with Puppeteer-Chromium

Comments

@nfwyst
Copy link

nfwyst commented Feb 26, 2019

  • Puppeteer version: 1.11.0
  • Platform / OS version: 10.14.3
  • Node.js version: 11.6.0

when it appear

I have some operations like pagination retrieval that take a long time, page.waitForSelector will throw "timeout error" event if there is element on the page, it seem like the session is closed or connection is closed but no any reject error tell.

What is the expected result?

Here is an example:

async function click(selector, page) {
    try {
      await page.waitForSelector(selector , {
        timeout: 1000
      })
      await page.click(selector)
    } catch (err) {
      throw err
    }
}

async function recordPrice(id, page) {
  try {
    await click(`.search_Table .bgcolor:nth-child(${id + 1}) .link`, page)
   await Promise.all([
    page.waitForSelector('.aui_state_focus', {
      timeout: 6000
    }),
    page.waitForSelector('.aui_dialog .table_list tbody tr:nth-child(2)', {
      timeout: 6000
    })
   ])
  } catch (err) {
    if (err.message.includes('No node found for selector') || err.message.includes('.search_Table')) {
      return false
    }
    throw err
  }
}

// ...
 let prices = [];
 for (let id = 0; id < feeLength; id++) {
      prices.push(await recordPrice(id, page))
 }
// ...

the click function inside recordPrice should not throw any error

What happens instead?

after recordPrice called multiple times, page.waitForSelector(.search_Table .bgcolor:nth-child(${id + 1}) .link) will throw timeout error, but I can get response from the console of headless chrome, so the element is exists actually.

another, if i comment this lines of click function:

  await page.waitForSelector(selector , {
        timeout: 1000
  })

the browser pages will be hanging and not end, its confused for me. so, how to fix this so i don't have to restart pages again ? thanks!

@matheusb-comp
Copy link

In the TimeoutError catch, did you try waitFor again with other selectors?

I was having a problem like this with Puppeteer v1.12.0, after some page.goto (5~15), all waitFor calls would stop responding (and eventually timeout).
I tried following the source code to understand what was happening, and for some reason the waitTasks are not being rerun in the _setContext function after the navigation breaks all currently listening waiFor calls.

For now I'm using v1.11.0, and this hasn't happened again.

@albertcarrete
Copy link

I was having a problem like this with Puppeteer v1.12.0, after some page.goto (5~15), all waitFor calls would stop responding (and eventually timeout).

You actually saved from a huge headache I was having on v1.12.2. On every 12th or 13th run of page.goto Puppeteer would simple stop responding and timeout any waitForSelector call. Using v1.11.0 fixed this issue as far as I can tell.

@nfwyst
Copy link
Author

nfwyst commented Feb 28, 2019

In the TimeoutError catch, did you try waitFor again with other selectors?

Yes, i did, but there is the same error.

@nfwyst
Copy link
Author

nfwyst commented Feb 28, 2019

I tried following the source code to understand what was happening, and for some reason the waitTasks are not being rerun in the _setContext function after the navigation breaks all currently listening waiFor calls.

So waitForSelector will not work if there are too much navigations.
I'm using v1.11.0 too, but the problem still exists.

@nfwyst nfwyst closed this as completed Feb 28, 2019
@nfwyst nfwyst reopened this Feb 28, 2019
@SimonSchick
Copy link

Running into this as well, issue is occurring in a semi-predictable manner.

@matheusb-comp
Copy link

matheusb-comp commented Feb 28, 2019

I'm using v1.11.0 too, but the problem still exists.

Strange, I did not see this happen again in v1.11.0.

Related older issue: #4011

@nfwyst
Copy link
Author

nfwyst commented Feb 28, 2019

It is because _setContext never be called with context again after the last waitTask has been init, then the waitTask throw timeout error.

@nfwyst
Copy link
Author

nfwyst commented Feb 28, 2019

I dont know why the context is missing

@nfwyst nfwyst changed the title page.waitForSelector timeout but the element does exists on the DOM page.waitForSelector timeout & ExecutionContext.evaluateHandle hanging Mar 1, 2019
@aslushnikov
Copy link
Contributor

@nfwyst this is a nasty bug. Any way I can repro locally? Looks like we don't force-create execution contexts in certain cases in Chromium.

@aslushnikov aslushnikov added bug chromium Issues with Puppeteer-Chromium labels Mar 1, 2019
@aslushnikov
Copy link
Contributor

Ah, this is a dupe of #4011

@nhhockeyplayer
Copy link

seeing same onlatest

@hack-tramp
Copy link

same problem on latest version

@Kradirhamik
Copy link

Any news on this one please? We're reproducing on the latest version

@BorisBosnar
Copy link

+1

1 similar comment
@daftclaud
Copy link

+1

@jnd0
Copy link

jnd0 commented Jul 16, 2020

Still the same problem is happening in v5.x

@talkl
Copy link

talkl commented Jul 21, 2020

also experiencing the same on v3.3.0 with the waitForFunction. This is a serious bug and our company relies on it.

@Kradirhamik
Copy link

Kradirhamik commented Jul 23, 2020

Seems like this works ok in Playwright

@talkl
Copy link

talkl commented Aug 24, 2020

Playwright

what is playwright?

@Gwen-M
Copy link

Gwen-M commented Oct 31, 2020

same problem on latest version

@MetaMmodern
Copy link

same on latest version

@eezdev
Copy link

eezdev commented Apr 7, 2021

+1

@dmanexe
Copy link

dmanexe commented Aug 15, 2021

+1, but also seems that waitFor randomly works and then does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium
Projects
None yet
Development

No branches or pull requests