COLD  Crypto
COLD Crypto

Reputation: 91

Puppeteer not working in headless mode with chromium

I'm using Puppeteer 1.20.0 with Chromium-browser v74 on Raspberry pi running Raspbian 10. Using the example code from Puppeteer Github page works as expected when running Puppeteer in headless disabled, however, if I try to run it in headless mode I get this error and it crashes.

UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected.

My Code:

const puppeteer = require('puppeteer-core');

(async () => {
    const browser = await puppeteer.launch({
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
        executablePath: '/usr/bin/chromium-browser',
        headless: true
    });
  const page = await browser.newPage();
  await page.goto('https://youtube.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

The same code works as expected both headless and non-headless in another Debian 10 machine. They both are running Puppeteer 1.20.0 the only difference is the Debian machine is running Google-chrome 77 whereas the Raspbian is running Chromium-browser 74.

I also tried the puppeteer-core version 1.13.0 which is the recommended version for chromium 74 but it also didn't work in headless mode.

Upvotes: 5

Views: 13235

Answers (3)

Muntakin
Muntakin

Reputation: 1

Puppeter comes with compatible chromium..in node_modules/puppeter/ look for .local-chromium if you don't find it I suggest delete node_modules and hit "npm i puppeteer"

Upvotes: 0

erickpeniche
erickpeniche

Reputation: 83

I finally was able to run puppeteer... but not on Raspbian buster. Here are the details of the environment where I successfully ran puppeteer:

  • Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
  • Raspbian Stretch (2019-04-08-raspbian-stretch)
  • NodeJS v12.10.0 & npm v6.10.3 (from nodesource)
  • [email protected]
  • chromium-browser Chromium 72.0.3626.121 Built on Raspbian , running on Raspbian 9.11

I did NOT use the downloaded chromium from puppeteer, I used the one that came with raspbian and added the "executablePath" config so I can only use "puppeteer-core"

Upvotes: 1

Kyle
Kyle

Reputation: 436

Puppeteer is only guaranteed to work with the version of chromium that it is bundled with (puppeteer rather than puppeteer-core). So you would probably have better luck running an older version of puppeteer that is built for chromium 74.

Upvotes: 0

Related Questions