puppeteer: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!

Minimal, reproducible example

const browser = await puppeteer.launch({
    headless: true,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
  });

Error string

Error: Timed out while waiting for the WS endpoint URL

Bug behavior

  • Flaky
  • PDF

Background

Using it inside docker image. Platform / OS version: Rocky Linux 8 running on GCP

I have tried multiple things

  • running node node_modules/puppeteer/install.js manually inside docker image.
  • verify all the dependencies are present for chrome with the help of ldd chrome

Expectation

Get the browser instance

Reality

It throws error

TimeoutError: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!
    at ChromeLauncher.launch (/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:153:23)

Puppeteer version

20.8.2

Node version

18.16.0

Package manager

npm

Package manager version

9.5.1

Operating system

Linux

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 14
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Adding timeout while launching the puppeteer will solve this issue. Try adding timeout:0 in launch options.

is anyone can find solution ?

Same issue, however, I will note that adding timeout: 0 as @rohinthr suggested, seems to solve it so far, however, I still need to do more testing to confirm.

On puppeteer v 21.1.1. Using google cloud function gen2 onObjectFinalized trigger with 16GiB memory, 4 cpu, and 120 second timeout.

On first, and intermittently on subsequent runs of this Cloud Storage trigger function, I am getting TimeoutError: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!. So, this is still very much an issue and unless someone can point out in my code something I’m missing, I am waiting for the browser to close before the function completes, etc.

In package.json I had to add:

"scripts": {
  "gcp-build": "node node_modules/puppeteer/install.js"
}

And then at root of project I added the .puppeteerrc.cjs config file:

const {join} = require('path');

/**
 * @type {import("puppeteer").Configuration}
 */
module.exports = {
    // Changes the cache location for Puppeteer.
    cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};

Puppeteer code:

const browser = await puppeteer.launch({
    headless: 'new',
    timeout: 0,
})

const page = await browser.newPage()

// Load the html file that triggered onObjectFinalized as string and pass to setContent
// So, in my use case I'm not even loading a website with puppeteer, just passing html.

await page.setContent(html, { waitUntil: 'domcontentloaded' })
await page.emulateMediaType('screen')

const PDF = await page.pdf({
    path: `/tmp/${pdfFilename}`,
    margin: { top: '.5in', right: '.5in', bottom: '.5in', left: '.5in' },
    printBackground: true,
    format: 'A4',
})

await browser.close()