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.

page.waitForSelector timeout & ExecutionContext.evaluateHandle hanging

See original GitHub issue
  • 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!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
hack-trampcommented, Jul 29, 2019

same problem on latest version

14reactions
nhhockeyplayercommented, Jun 13, 2019

seeing same onlatest

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer / Node.js to click a button as long as it exists
If it's not displayed, the timeout would otherwise default to 30000 and that's far too long to have your code hanging around waiting....
Read more >
Puppeteer documentation - DevDocs
Frame has at least one execution context - the default execution context - where ... evaluateHandle(() => document.body); const resultHandle = await page....
Read more >
API Reference — Pyppeteer 0.0.25 documentation
Execute function on this page. Difference between evaluate() and evaluateHandle() is that evaluateHandle returns JSHandle object (not value).
Read more >
/vendor/puppeteer/docs/api.md | puppeteer_plus@0.12.0 | Deno
Defaults to `false`. - `timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout....
Read more >
try - Mercurial - Mozilla
waitForSelector Page.waitForSelector is shortcut for main frame (waittask.spec.ts)": [ "PASS" ], "waittask specs Frame.waitForSelector should run in ...
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