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

fix(page): fix race condition in WaitTask #2739

Merged
merged 1 commit into from Jun 14, 2018

Conversation

aslushnikov
Copy link
Contributor

This patch eliminates a common race condition with WaitTask, that
happens when predicate function gets resolved right before the execution
context gets destroyed.
This situation results in a "Cannot find context with specified id undefined"
exception.

Credits go to @jakub300 for his wonderful investigation.

Fixes #1325.

This patch eliminates a common race condition with WaitTask, that
happens when predicate function gets resolved right before the execution
context gets destroyed.
This situation results in a "Cannot find context with specified id undefined"
exception.

Credits go to @jakub300 for his wonderful [investigation](puppeteer#1325 (comment)).

Fixes puppeteer#1325.
Copy link
Collaborator

@JoelEinbinder JoelEinbinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@aslushnikov aslushnikov merged commit ddfdaf9 into puppeteer:master Jun 14, 2018
@7starsone
Copy link

7starsone commented Jun 20, 2018

Hello, I tried to edit .../node_modules/puppeteer/lib/FrameManager.js in a project.... but I get the same error despite of that. Maybe is that not enough and do I need to do something else? Or is this fix really not definitive? Thanks

@aslushnikov
Copy link
Contributor Author

@7starsone try installing puppeteer@next and see if it helps you.

@7starsone
Copy link

7starsone commented Jun 20, 2018

Hello, if it helps I'm using this https://github.com/nesk/puphpeteer but the owner banned me from comments because of Cannot find context with specified id undefined 😆 because not about his work and he stated that I didn't provide all the details but I did it, a code example, the logger, the used software versions and so on... and still had some issues with crashing script (not about my php code but the try catch not working and sometimes even if the URLs are from the same website and the page structure is the same...) like this, then "...Unexpected token { in JSON at position..." and "listen EADDRINUSE". Here the entire discussion rialto-php/puphpeteer#7

Thank you very much

@aslushnikov
Copy link
Contributor Author

@7starsone Looks like you have multiple issues going on.

  • The "unexpected token" comes from the syntax error in javascript code
  • The "listen EADDRINUSE" comes from trying to use occupied HTTP port.

These all have nothing to do with "Cannot find context with specified id", which usually happens because page navigates away while you're trying to page.evaluate in it.

If you have a puppeteer script that reproduces the problem with current puppeteer tip-of-tree and which I can run locally, please file a bug and we'll try to see what's going on.

@7starsone
Copy link

7starsone commented Jun 20, 2018

@aslushnikov "error in javascript code" what javascript code? Something in the project from puppeteer or that one coming from the page content when goto URL?
The error on log is related to the line 230 of ProcessSupervisor.php where he (?) does a checkProcessStatus(); but it doesn't seem to be related to javascript...maybe you could take a look at that code.
Then, "These all have nothing to do with" that was clear, I just listed what issues were detected...that cause a crash and not only an exception to handle. Indeed, I have not a javascript code because I code in php in this case and the procedure often stops because of those external errors. Thanks

p.s.: but the funny thing is also that he himself on code comments of that file writes..."...if the process crash while executing the instruction" so already foresees a crash, which should not be there because in my opinion the goto function should just retrieve the page content after 'waitUntil' => 'networkidle0' and if it can't, if the URL is invalid, a 404 or no content after the timeout...it should not crash because of this reason but just handle an exception, so you could retry at another time or investigate about that specific bad/strange URL. So, the process crash, what's the real reason about it? A mistery.

@7starsone
Copy link

7starsone commented Jun 22, 2018

Hello, please, can you explain how to change the used port? (on the /lib folder? where?) The problem is that on documentation of nesk/puphpeteer this is not explained and not even here. Unfortunately, listen EADDRINUSE is really annoying and slows down everything because even if I launch a script one time a minute in case it's not running, this condition may persist for many minutes...and also, still not clear where "...Unexpected token { in JSON at position..." comes from 😉
thank you

p.s.: on CentOS 7 I did
setcap 'cap_net_bind_service=+ep' /usr/bin/node
and at the moment, it seems to fix the listen EADDRINUSE, at least
Update: I'm afraid not, it's not fixed, the error is always there, again and nowhere is explained how to manage puppeteer/puphpeteer in this case and when I wrote issue about this I was asked for a log. Provided the log (even if someone should know how to fix this irrespective of a log...) anyway, no solution and no explanation, on the contrary an unjustified ban from comments instead 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When would an error "Cannot find context with specified id undefined" happen?
3 participants