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
Protocol error (Runtime.callFunctionOn): Target closed. #6610
Comments
@mahnunchik Why didn't you |
@marr omitted
When it is required to wait at least one element from set of elements. |
@marr still has a good point, in that you need know that each of those race operations are complete before closing the page out from under them. Consider this:
It might also be possible to put a catch on each of your operations, so that their failure doesn't cause an error in your scripting:
|
The cause of the error has been found and the problem has been resolved |
Some links I have looked at: https://stackoverflow.com/questions/51857070/puppeteer-in-nodejs-reports-error-node-is-either-not-visible-or-not-an-htmlele/66537619#66537619 https://stackoverflow.com/questions/70426622/javascript-puppeteer-error-node-is-either-not-clickable-or-not-an-htmlelement puppeteer/puppeteer#6610 https://stenciljs.com/docs/end-to-end-testing#type-inside-an-input-field jestjs/jest#5018 I have not yet looked at the second to last comment under the last link above: jestjs/jest#5018 (comment) That seems like it could be promising. It also further links to: https://stackoverflow.com/questions/50807170/jest-test-fails-when-trying-to-test-an-asynchronous-function-throws
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
I reproduced this issue in v10.2.0. My code is: ` const browser = await puppeteer.launch({
` It was 100% reproducible, url: https://www.era.nl/huizenaanbod
waitForSelector was causing the behavior. |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
You should await the calls before you close the page. Otherwise, they will run on a closed target throwing the error. |
kind of stuck there problem mentioned on puppeteer/puppeteer#6610 ,found no solutions as of rn.
vc |
To all those who come across this issue, I am sharing my own personal resolution: (typescript)
In this way, you can wrap all critical promises inside the CPromise.$$() function (or $$()) and cancel them before closing the page.
|
I Just had this issue, to be honest i couldn't find a solution in any of these comments or elsewhere, so i managed to find my own way around. Here is an overview of my understanding and solution. By the way my javascript solution is inspired by @stramanu's solution in typscript. Why this error?The error Solution:Ensure all promises are resolved, make sure that all promises are resolved before closing the browser or page. You can use like in my case, i just had to wrap my call in a await Promise.all([
// Your Puppeteer operations
]);
// Close the page
await page.close();
// Close the browser
await browser.close(); In simple words, the idea is to wrap whatever iteration you are doing in a promise and make sure it is all resolved before you close the page and browser. Works like charm✨ |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
Please include code that reproduces the issue.
What is the expected result?
Closing the page normally without errors.
What happens instead?
The text was updated successfully, but these errors were encountered: