puppeteer: page.waitForSelector timeout & ExecutionContext.evaluateHandle hanging
- 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!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 23 (2 by maintainers)
same problem on latest version
seeing same onlatest
Any news on this one please? We’re reproducing on the latest version
same on latest version
same problem on latest version
+1, but also seems that waitFor randomly works and then does not work.
Still the same problem is happening in v5.x
also experiencing the same on v3.3.0 with the waitForFunction. This is a serious bug and our company relies on it.
In the
TimeoutError
catch, did you trywaitFor
again with other selectors?I was having a problem like this with Puppeteer v1.12.0, after some
page.goto
(5~15), allwaitFor
calls would stop responding (and eventually timeout). I tried following the source code to understand what was happening, and for some reason thewaitTasks
are not beingrerun
in the_setContext
function after the navigation breaks all currently listeningwaiFor
calls.For now I’m using v1.11.0, and this hasn’t happened again.