question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

browser.newPage freezes (never resolves)

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.12.2
  • Platform / OS version: Ubuntu 16.04.5 & macOS
  • Node.js version: 11.10

What steps will reproduce the problem?

Here’s the exact code I’m using:

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

With the following dockerfile:

FROM node:11

########################################################################################################################
# Puppeteer Begin
########################################################################################################################

# See https://crbug.com/795759
RUN apt-get update && apt-get install -yq libgconf-2-4

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer installs, work.
RUN apt-get update && apt-get install -y wget --no-install-recommends \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
      --no-install-recommends \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get purge --auto-remove -y curl \
    && rm -rf /src/*.deb

########################################################################################################################
# Puppeteer End
########################################################################################################################

# Create app directory
WORKDIR /usr/src/app

# Install dependencies
COPY package.json .
COPY package-lock.json .
RUN npm install

# Bundle remaining sources
COPY . .

EXPOSE 3000

CMD [ "node", "./bin/www" ]

What is the expected result?

I expect the browser.newPage promise to always resolve or reject.

What happens instead?

After running this code for several hours with many iterations of the above code snippet, the browser.newPage promise will eventually not resolve nor reject causing my application to hang.

Note: Problem goes away when downgrading to puppeteer 1.11.0

Edit: Actually, downgrading to 1.11.0 did not help…

See older similar issue: https://github.com/GoogleChrome/puppeteer/issues/1409#issuecomment-464866096

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:12
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
justinmealeycommented, Feb 27, 2019

I solved the problem by setting the browser to use pipe instead of websocket:

const browser = await puppeteer.launch({ pipe: true });

4reactions
hg8commented, Feb 25, 2019

Having the same problem I managed to fix it this way :

# Install chromium separately
sudo apt install chromium-browser
# Install puppeteer CORE version 1.11.0
npm install puppeteer-core@1.11.0

Then in my code:

const puppeteer = require('puppeteer-core');
const browser = await puppeteer.launch({
	executablePath: '/usr/bin/chromium-browser',
        headless: false,
      });

Hope this can be helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer newPage() freezes/ never resolves nor rejects ...
My Problem is that the browser.newPage() function never resolves. So basicly in the console it alsways loggs Start but never 1 nor 2....
Read more >
Puppeteer causes Firefox to freeze because stdout/stderr ...
It simply loads the given page, and then quits the browser. But closing the browser hangs, and Firefox never quits. Even the shutdown...
Read more >
Puppeteer browser hanged on newPage() on Web App ...
I have published a node.js to Web App Service (Linux with Node 14) that using puppeteer browser to download pdf.
Read more >
Getting to Know Puppeteer Using Practical Examples
In the code example above we plainly create a new page by invoking the newPage method. Notice it's created on the default browser...
Read more >
Page | Playwright - CukeTest
Page provides methods to interact with a single tab in a Browser, ... the page will freeze waiting for the dialog, and actions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found