puppeteer: Page throws timeout exception only in headless mode
Tell us about your environment:
- Puppeteer version: puppeteer@next (latest commit)
- Platform / OS version: macOS High Sierra 10.13.1
- URLs (if applicable): http://www.sanident.it
- Node.js version: v8.6.0
What steps will reproduce the problem?
const browser = await puppeteer.launch({
headless: true,
});
const page = await browser.newPage();
await page.goto("http://www.sanident.it", {timeout: 10000});
console.log(await page.content());
What is the expected result?
Promise does not throw “Navigation Timeout Exceeded” no matter if using headless or non-headless mode.
What happens instead?
Promise throws “Navigation Timeout Exceeded” ONLY in headless mode. In non-headless it works fine. This does not work also in v0.13.0 BUT IT WORKS in v0.12.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 15 (2 by maintainers)
Some websites block headless useragent. You might try to change that.
I ended up on this thread because I was doing
page.goto('localhost:3000')
instead ofpage.goto('http://localhost:3000')
. The protocol seems mandatory in headless mode. Hope this helpsCan confirm this with puppeteer 2.1.1 running in windows and mac.
This should be documented somewhere.
In headless mode browser cache is PRESERVED, so you can’t catch all of your precious requests! But in ‘headful’ mode cache somehow gets reset. Just do this:
I can confirm that this timeouts in headless and not headful mode. Perhaps the site does some kind of headless/automation sniffing and something is blocking the page from finishing?
In my case I forced the resolution I used in development and it worked normally
I had same error, but navigation was caused by click event. Resolved according to the API document, with sample code snippet:
I can confirm, setting the
defaultViewPort
at launch solved this issue for me. Thanks @fclebio 🙏🏽