-
Notifications
You must be signed in to change notification settings - Fork 9k
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
[Bug]: puppeteer 20.6.0 introduced a regression (with iframe?) that now is Error: Requesting main frame too early! #11246
Comments
This issue was not reproducible. Please check that your example runs locally and the following:
Once the above checks are satisfied, please edit your issue with the changes and we will |
@andreabisello can you create a test page that resembles the real issue? |
The error indicates that there is an action on the main frame but Puppeteer has not received the information about the main frame from the browser yet. Perhaps it is a race condition but it would also depend on how exactly the frame is accessed. |
@OrKoN i cant because is company code that test company software. maybe i should create a website with an iframe and a button that open that iframe, makes something, and close the iframe. they way i access the frame is that one
then i make every interation using "creationFrame" , for clicking typing etc ...
the problem raise. maybe i could wrap that evaluate in a try - catch expecting some kind of exception. now i try. |
I had a simmilar Error with Puppeteer Version 21.4.1 but that is fixed for me with Version 21.5.0 now |
This issue still persists in version 21.5.2 and it cannot be reproduced reliably. |
I'm using 21.4.1 also another important thing: The problem only happens after launching a new browser instance, first time launch works fine with no problem at all, when my first task is finished I close the browser with browser.close() and when I start the next task I open the browser again with puppeteer.launch() + browser.newPage() => and here where the problem happens Note: I'm using "puppeteer-extra" which is built in top of "Puppeteer" |
I found a solution!1 - Upgrade to 21.5.2
upload service
what I basically did is I changed this line of code on my channelService and it works |
I was able to reproduce this when one of the args for puppeteer launch had "--single-process", when removing it it worked fine. |
This issue still persists in version in 21.5.2.
|
This issue still persists in version in 21.3.8. puppeteer-extra 3.3.6
|
This still happen with puppeteer 21.6.0 I cannot share the code too as this is a SSO login page from Microsoft for a large company, but basically the browser crashes when the page loads the login form with: Error: Requesting main frame too early! This does not occur up to 21.4.1 |
Confirmed, I have the same error and probably associated with iframes |
I've encountered a similar phenomenon. It occurs about once in every ten times. I am running Puppeteer version 21.5.2 on AWS Lambda. The process involves accessing three URLs twice each, and usually, this error occurs on the sixth and final access. I am accessing all of them using goto. Also, there is a process where I take about ten screenshots along the way. |
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. |
"puppeteer": "^21.9.0", the error occurs randomly when I try to call page.url() after page.goto and 2500 ms timeout |
have same error, when i do 20 times goto, it giving this error and my process hang up |
Are you awaiting page.goto to finish properly? if it's timing out or you are not awaiting it, the frame might not be there yet resulting in this error if you try to access it. Could anyone provide a minimal reproducible example? |
i have one browser which 20 tabs (for example) then i open this tabs, and i have express server. /add route, when user reach this route, my code find free tab, open site, make screenshot, when i launch 3 tasks two times, after some 10-20 seconds it hang and show this exception, then page.url() crash app. |
i also figured out, and with createIncognitoBrowserContext all works fine, i just create new context when need newPage, and closing context also with page.close(). |
also can confirm it happen only with headless mode, in non headless all works fine |
If someone is able to provide a minimal reproducible example to confirm the scenario, it would be great. |
I think I've found the solution.I posted it on stackoverflow and I'll post it here If you look in the puppeteer docs, it says a puppeteer instance is set to timeout in 30000ms (30seconds) by default. so when initialising the instance set the timeout option higher. I set mine to 31536000000ms (365 days)
|
@mshokoya How to catch a possible error when launch is not launched within 30 seconds? |
@alexey-sh I can think of 2 ways to catch the errors in puppeteer
But for the 'Error: Requesting main frame too early!' error. It can be prevented by increasing the default timeout set by puppeteer. (I increased mine from the default 30 seconds to 356days). you can increase it by whatever you want, it could be 60 seconds, it could be 1 hour. e.g
hope this answers your question |
@mshokoya What you showed is not a solution to the problem at all, as the browser opens in less than 30 seconds. |
@shadaxv after puppeteer launches ( i.e new page is open) the 30 second count down is started. after the 30 second countdown the page automatically closes due to the timeout being reached... if you then try to call a page method ( i.e page.waitForSelector() ) you will get the error
in other words the error occurs when you try to call a page method ( i.e page.url() or page.$ ) when the page does not exist have you tried my solution ? did it not work for you ? |
@mshokoya timeout is
I have tried your solution and it is not working for me, in my case, the problem is irregular, and so far no solution I have tried has gotten rid of it |
@shadaxv well it works for me. Ive tested it multiple times, if I leave it out, error occurs within 30 seconds. I set the timeout limit higher and I don't get the error. it may not work for you but it may work for someone else |
Although #11246 has no reproducible example and the root cause might be accessing main frames while they are navigating, this PR adds a workaround to retain a potentially stale main frame to prevent assertion errors.
Although #11246 has no reproducible example and the root cause might be accessing main frames while they are navigating, this PR adds a workaround to retain a potentially stale main frame to prevent assertion errors.
Although #11246 has no reproducible example and the root cause might be accessing main frames while they are navigating, this PR adds a workaround to retain a potentially stale main frame to prevent assertion errors.
Is there a fix for this? it happens randomly with high probability which makes the automation nearly unusable.. |
Although #11246 has no reproducible example and the root cause might be accessing main frames while they are navigating, this PR adds a workaround to retain a potentially stale main frame to prevent assertion errors.
Although #11246 has no reproducible example and the root cause might be accessing main frames while they are navigating, this PR adds a workaround to retain a potentially stale main frame to prevent assertion errors.
Also looking for help on this one it append when I try to make async with puppetter when I launch other browser instances after closing the old ones, I use also puppetter-extra and I make use of waitForSelector
|
Same issue, any updates? |
@nodegin the fix was released in these days, did you try to update? i tried, but because waitForTimeout was (correctly) removed i have to update my old testsuite in a lot of different places so until now i was not able to make a full run. |
I was seeing occasional Before:
After:
|
@charliefuller that makes sense, does the detached frame error indicate which page is detached for you? is the page perhaps crashed or you are using a stale page reference? We do not have a reproducible example for this issue so it probably just pages that crash or stale references. With the assertion not firing it is now possible to catch it. If anyone has a reproducible example, please share it. |
@OrKoN No but we only use one page. I don't think it's crashed or is a stale page reference. |
@charliefuller do you have a reproducible example? is the page in the middle of another navigation/aborted/errored navigation when this happen? |
@OrKoN It seems to happen randomly but when it does happen it's usually while waiting on |
@charliefuller is it possible that sometimes waitForFunction keeps running while the page is navigating/redirecting? Perhaps, sometimes the waiting is done before the page somehow goes stale? it would be really great to get some example of what sort of interactions are happening. For example, we use Puppeteer in Chrome DevTools tests and we have not once caught this issue (same with our own tests) and we do a fair bit of waitForFunction/navigations on a single page. Are you running this on third party pages? is there a pattern in what sites it happens on? |
In my case it is happening for some particular session and also very rarely,other sessions are working smoothly . by making protocol Timeout can we overcome this error or do we have any other solution for this . puppeteer version which i have is 22.8.0 |
Minimal, reproducible example
i can't give the code to reproduce because is a business code, so probably this will be a "closed" ticket, but anyway i can describe it, i hope can be useful.
the same error is repored here by other users, no one could understand how to reproduce systematically.
Error string
Error: Requesting main frame too early!
Bug behavior
Background
i open a browser, i open a page, a navigate to a webpage, i click a button, that opens a iframe, i take a reference to the iframe, i write some text, i click a button that close the iframe, and the error occur and the browser is closed (or the browser is closed and then the error occur).
that test worked for 2 years until the introduction of puppeteer 20.6.0
the website still the same
Expectation
when the website close the iframe, the execution of the code should keep working.
Reality
when, clicking a button, the website close the iframe, the browser close and the error is raised (or the error is raised and so the browser close)
until puppeteer 20.5.0 this was working.
with puppeteer 20.6.0 you obtain
with puppeteer 21.3 or also 21.4.1 you obtain
Puppeteer configuration file (if used)
No response
Puppeteer version
21.4.1
Node version
18.16.1
Package manager
npm
Package manager version
9.5.1
Operating system
Windows
The text was updated successfully, but these errors were encountered: