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
Waiting for both load
and networkIdle
#805
Comments
Hello, I can't help with your new feature request but based on what you want to establish, your code wont work. You state that you want to wait for the load and network idle event before you navigate to the page but Promise.all runs the promises in parallel and doesn't guarantee an order. So in your case, any one of your promises might run first. I suggest you do a Promise.all that includes your 2 waitForNavigation promises and then, only when the both promises have resolved, go to url. |
I think you misinterpret the function in It will become racy when they put an It's true that the promises can be resolved in any order. But the setup still happens in a defined order, in the current code. |
@katp4 Would also like to add that there is another problem with the pattern you propose. It lies in catching the errors; async function doSomething () {
const promise = new Promise((resolve, reject) => setTimeout(reject, 500));
await new Promise(resolve => setTimeout(resolve, 1000));
await promise;
} would result in an uncaught exception, even when: doSomething().catch(e => console.log('caught', e)); |
That's reasonable. That's an opportunity to remove the I'd do: await page.goto('https://example.com', {
waitLoad: true,
waitNetworkIdle: true // defaults to false
}); |
@aslushnikov and what about having the |
@Janpot that should work as well when we migrate onto lifecycle events. The plan is to keep lifecycle state for every frame. |
Ah great, I saw those new |
This patch adds support to multiple events that could be passed inside navigation methods: - Page.goto - Page.waitForNavigation - Page.goForward - Page.goBack - Page.reload Fixes puppeteer#805
@Janpot lifecycle events turned out to be insufficient for this. We'll need to plumb the navigationIds/documentIds through the protocol as well. I'll scope this bug to the initially suggested array of strings. |
This patch adds support to multiple events that could be passed inside navigation methods: - Page.goto - Page.waitForNavigation - Page.goForward - Page.goBack - Page.reload Fixes #805
…er#1147) This patch adds support to multiple events that could be passed inside navigation methods: - Page.goto - Page.waitForNavigation - Page.goForward - Page.goBack - Page.reload Fixes puppeteer#805
Some pages will fire load event before network goes idle, some after. I'd like to wait for both events to have happened before considering a page 'navigated'. Currently looking at the
watchdog
code it seems like it's either one or the other. The way to do it right now is:But it seems to me that this is a functionality that deserves a more straightforward out-of-the-box solution. for instance:
Or assume that people that wait for
'networkidle'
also always want to wait for'load'
.PS: I might be wrong about this, but after digging through the code, it seems to me that this function doesn't take the actual state into account. For instance it won't work if the load event has already fired or if the network is already idle.
The text was updated successfully, but these errors were encountered: