Open dulnan opened 5 months ago
Hey @dulnan! I'm here to assist with any bugs, questions, or contributions you have. Let's tackle this issue together!
To resolve the issue where setting javaScriptEnabled: false
in the createPage()
method never loads the page because the method always waits for hydration to finish, you need to modify the waitForHydration
function to check if JavaScript is enabled before waiting for hydration. If JavaScript is disabled, the function should not wait for hydration.
Here is the modified code:
export async function waitForHydration(page: Page, url: string, waitUntil?: GotoOptions['waitUntil']): Promise<void> {
const javaScriptEnabled = await page.evaluate(() => typeof window !== 'undefined');
if (javaScriptEnabled) {
if (waitUntil === 'hydration') {
await page.waitForFunction(() => window.useNuxtApp?.().isHydrating === false);
} else if (waitUntil === 'route') {
await page.waitForFunction(route => window.useNuxtApp?.()._route.fullPath === route, url);
}
}
}
This modification ensures that the waitForHydration
function only waits for hydration if JavaScript is enabled [1].
To continue talking to Dosu, mention @dosu.
Environment
Reproduction
Call
createPage()
by passingjavaScriptEnabled: false
in the options:Describe the bug
This will never finish loading the page because the
createPage
method always waits for hydration to finish. In this case, hydration can't ever finish, so the method's Promise never resolves.Additional context
Probably a rare use case, but I ran into this issue while explicitly wanting to test the unhydrated SSR output of a page.
Logs
No response