Puppeteer just hangs with default Chrome installation
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.11.0
- Platform / OS version: Linux Ubuntu 14.04 x86_64
- URLs (if applicable):
- Node.js version: 10.14.1
What steps will reproduce the problem?
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36');
await page.setViewport({width:960,height:768});
await page.goto('https://google.com/', {timeout: 40000, waitUntil: 'domcontentloaded'});
await page.screenshot({ fullPage: true, path: 'screenshot.jpg' });
await browser.close();
})();
- Install
puppeteer
withnpm i puppeteer
command . - Run this code sample with
node make-screenshot.js
command to make a screenshot of webpage.
What is the expected result? Puppeteer should save screenshot as expected.
What happens instead? Puppeteer just hangs, timeout doesn’t work.
How to fix it now?
I solved it by installing chromium-browser
separately:
sudo apt update
sudo apt install -y chromium-browser
chromium-browser --version
And then we have to change executable path in the code example to make it work:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({executablePath: 'chromium-browser'}); // <- set path for chromium browser
const page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36');
await page.setViewport({width:960,height:768});
await page.goto('https://google.com/', {timeout: 40000, waitUntil: 'domcontentloaded'});
await page.screenshot({ fullPage: true, path: 'screenshot.jpg' });
await browser.close();
})();
Now it works fine for me.
So that puppeteer-core
and chromium-browser
should be installed insted of just puppeteer
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Puppeteer just hangs with default Chrome installation #3620
Node.js version: 10.14.1. What steps will reproduce the problem? const puppeteer = require('puppeteer'); (async() => ...
Read more >Puppeteer Hangs In Headless Mode - Stack Overflow
Here's my setup function for my Puppeteer instance: setUpPuppeteer: async () => { const headless = process.env.NODE_ENV === " ...
Read more >Troubleshooting - Puppeteer
Make sure all the necessary dependencies are installed. You can run ldd chrome | grep not on a Linux machine to check which...
Read more >Puppeteer Tutorial | Fixing Common Errors while installing ...
This tutorial troubleshoots common errors in Puppeteer. Using the commands and methods provided based on error scenarios, one can fix the ...
Read more >Chrome tabs intermittent hang or crash with white screen
Problem description: Our users, at seemingly random intervals, experience their tabs going completely white and becoming non responsive. The ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aslushnikov that doesn’t seem right. Chromium is packaged with Puppeteer, we don’t control the version of Chromium separately. When we do an npm install, Puppeteer automatically chooses the Chromium version it wants via a script. Puppeteer v1.10.0 specifies to use Chromium revision 599821:
https://github.com/GoogleChrome/puppeteer/blob/v1.10.0/package.json#L11
Shouldn’t Puppeteer specify a version of Chromium it’s compatible with?
where the puppet-core usage anyway?