puppeteer: browser.newPage freezes

Steps to reproduce

  • Puppeteer version: 0.13.0
  • Platform / OS version: Clever Cloud scaler (linux exherbo)

What steps will reproduce the problem?

Here is the code:

const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({ executablePath = '/usr/bin/chromium' });
console.log(browser);
const page = await browser.newPage();
console.log(page);

The code never reaches the console.log(page).

Here is the logs, with DEBUG=puppeteer:*

2017-11-17T13:00:51.063Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol SEND ► {"id":1,"method":"Target.setDiscoverTargets","params":{"discover":true}}
2017-11-17T13:00:51.063Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"4c5efd2b-a8b4-449e-bdb8-5c33dae85332","type":"browser","title":"","url":"","attached":true}}}
2017-11-17T13:00:51.063Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"5518b1d4-c7e9-4162-a914-6398a1516d22","type":"page","title":"","url":"about:blank","attached":false}}}
2017-11-17T13:00:51.064Z:  _maxListeners: undefined,
2017-11-17T13:00:51.064Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"cbd9d93e-643a-4f4c-a6df-55f15f85c1cf","type":"browser","title":"","url":"","attached":false}}}
2017-11-17T13:00:51.064Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"id":1,"result":{}}
2017-11-17T13:00:51.064Z: Browser {
2017-11-17T13:00:51.064Z:  domain: null,
2017-11-17T13:00:51.064Z:  _events: {},
2017-11-17T13:00:51.064Z:  _eventsCount: 0,
2017-11-17T13:00:51.065Z:  _ignoreHTTPSErrors: false,
2017-11-17T13:00:51.065Z:  _appMode: false,
2017-11-17T13:00:51.065Z:  _screenshotTaskQueue: TaskQueue { _chain: Promise { undefined } },
2017-11-17T13:00:51.065Z:  _connection:
2017-11-17T13:00:51.065Z:   Connection {
2017-11-17T13:00:51.065Z:     domain: null,
2017-11-17T13:00:51.066Z:        'Target.targetInfoChanged': [Function: bound _targetInfoChanged] },
2017-11-17T13:00:51.066Z:     _eventsCount: 3,
2017-11-17T13:00:51.066Z:     _maxListeners: undefined,
2017-11-17T13:00:51.066Z:     _url: 'ws://127.0.0.1:44123/devtools/browser/3c769f8c-7e3a-4eaf-b662-9cea95339100',
2017-11-17T13:00:51.066Z:     _events:
2017-11-17T13:00:51.066Z:      { 'Target.targetCreated': [AsyncFunction: bound _targetCreated],
2017-11-17T13:00:51.066Z:        'Target.targetDestroyed': [AsyncFunction: bound _targetDestroyed],
2017-11-17T13:00:51.067Z:     _delay: 0,
2017-11-17T13:00:51.067Z:     _ws:
2017-11-17T13:00:51.067Z:      WebSocket {
2017-11-17T13:00:51.067Z:     _lastId: 1,
2017-11-17T13:00:51.067Z:        domain: null,
2017-11-17T13:00:51.067Z:     _callbacks: Map {},
2017-11-17T13:00:51.067Z:        _events: [Object],
2017-11-17T13:00:51.068Z:        extensions: {},
2017-11-17T13:00:51.068Z:        _eventsCount: 4,
2017-11-17T13:00:51.068Z:        _maxListeners: undefined,
2017-11-17T13:00:51.068Z:        readyState: 1,
2017-11-17T13:00:51.068Z:        protocol: '',
2017-11-17T13:00:51.068Z:        bytesReceived: 530,
2017-11-17T13:00:51.069Z:        _finalize: [Object],
2017-11-17T13:00:51.069Z:        _closeTimer: null,
2017-11-17T13:00:51.069Z:        _finalizeCalled: false,
2017-11-17T13:00:51.069Z:        _binaryType: 'nodebuffer',
2017-11-17T13:00:51.069Z:        _closeMessage: null,
2017-11-17T13:00:51.070Z:        _socket: [Object],
2017-11-17T13:00:51.070Z:        _receiver: [Object],
2017-11-17T13:00:51.070Z:        _sender: [Object],
2017-11-17T13:00:51.070Z:        _closeCode: null,
2017-11-17T13:00:51.071Z:        protocolVersion: 13,
2017-11-17T13:00:51.071Z:        _isServer: false,
2017-11-17T13:00:51.071Z:        _ultron: [Object],
2017-11-17T13:00:51.071Z:        url: 'ws://127.0.0.1:44123/devtools/browser/3c769f8c-7e3a-4eaf-b662-9cea95339100',
2017-11-17T13:00:51.072Z:     _sessions: Map {},
2017-11-17T13:00:51.072Z:     _closeCallback: [Function] },
2017-11-17T13:00:51.072Z:        _req: null },
2017-11-17T13:00:51.073Z:  _closeCallback: [Function: killChrome],
2017-11-17T13:00:51.073Z:     '4c5efd2b-a8b4-449e-bdb8-5c33dae85332' => Target {
2017-11-17T13:00:51.073Z:  _targets:
2017-11-17T13:00:51.073Z:   Map {
2017-11-17T13:00:51.073Z:     _browser: [Circular],
2017-11-17T13:00:51.074Z:     _pagePromise: null,
2017-11-17T13:00:51.074Z:     _initializedCallback: [Function],
2017-11-17T13:00:51.074Z:     _initializedPromise: [Object],
2017-11-17T13:00:51.074Z:     _targetInfo: [Object],
2017-11-17T13:00:51.075Z:     _isInitialized: true },
2017-11-17T13:00:51.075Z:     '5518b1d4-c7e9-4162-a914-6398a1516d22' => Target {
2017-11-17T13:00:51.075Z:     _browser: [Circular],
2017-11-17T13:00:51.075Z:     _targetInfo: [Object],
2017-11-17T13:00:51.075Z:     _pagePromise: null,
2017-11-17T13:00:51.075Z:     _initializedCallback: [Function],
2017-11-17T13:00:51.076Z:     _initializedPromise: [Object],
2017-11-17T13:00:51.076Z:     _isInitialized: true },
2017-11-17T13:00:51.076Z:     'cbd9d93e-643a-4f4c-a6df-55f15f85c1cf' => Target {
2017-11-17T13:00:51.076Z:     _browser: [Circular],
2017-11-17T13:00:51.076Z:     _targetInfo: [Object],
2017-11-17T13:00:51.077Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:browser browser.newPage()
2017-11-17T13:00:51.077Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol SEND ► {"id":2,"method":"Target.createTarget","params":{"url":"about:blank"}}
2017-11-17T13:00:51.077Z:     _pagePromise: null,
2017-11-17T13:00:51.077Z:     _initializedCallback: [Function],
2017-11-17T13:00:51.077Z:     _initializedPromise: [Object],
2017-11-17T13:00:51.077Z:     _isInitialized: true } } }
2017-11-17T13:00:51.078Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"b173b49e-99c7-4165-885f-0745f2aa21eb","type":"page","title":"","url":"","attached":false}}}
2017-11-17T13:00:51.078Z: Fri, 17 Nov 2017 13:00:50 GMT puppeteer:protocol ◀ RECV {"id":2,"result":{"targetId":"b173b49e-99c7-4165-885f-0745f2aa21eb"}}
2017-11-17T13:01:49.812Z: ::ffff:62.210.92.244 - GET /export_to_pdf HTTP/1.1 - - - - ms

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 51 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Issue persist with puppeteer@5.2.1 and Chromium (782078) (default downloaded by npm installing puppeteer) Node version 14.8.0

my code:

(async () => {
  const browser = await puppeteer.launch({headless: true});
  console.log('page get started');
  const page = await browser.newPage();
  console.log('?');
  await page.goto('https://google.com');
  await page.pdf({path: 'google.pdf'});

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

“?” is never printed. In non-headless it runs but fails on pdf which is expected.

Is there a new already open issue for this somewhere?

@aslushnikov’s suggestion has worked for me. I was able to make it work in a CircleCI environment with:

const browser = await puppeteer.launch({
  args: ['--single-process']
});

I wish the error message was more helpful. I was only getting a timeout message after 8 minutes:

{ Error: Protocol error (Page.enable): Target closed.
    at Promise (/home/circleci/nexgen/node_modules/puppeteer/lib/Connection.js:186:56)
    at new Promise (<anonymous>)
    at CDPSession.send (/home/circleci/nexgen/node_modules/puppeteer/lib/Connection.js:185:12)
    at Function.create (/home/circleci/nexgen/node_modules/puppeteer/lib/Page.js:44:18)
    at _pagePromise._sessionFactory.then.client (/home/circleci/nexgen/node_modules/puppeteer/lib/Target.js:43:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  -- ASYNC --
    at Target.<anonymous> (/home/circleci/nexgen/node_modules/puppeteer/lib/helper.js:144:27)
    at Browser._createPageInContext (/home/circleci/nexgen/node_modules/puppeteer/lib/Browser.js:177:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  -- ASYNC --
    at Browser.<anonymous> (/home/circleci/nexgen/node_modules/puppeteer/lib/helper.js:144:27)
    at /home/circleci/nexgen/app/tests/chart/chart-test.js:13:36
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) message: 'Protocol error (Page.enable): Target closed.' }

I think this issue shouldn’t be closed, it still exists in new version of puppeteer.

Adding --disable-gpu resolved this in my instance.

Chrome Version: Chrome/92.0.4515.159 with puppeteer ^10.2.0

Yep - 1.11.0 downgrade solved this for me too!

Had the same issue with Puppeteer 1.12.2. I locked the version to 1.11.0 and it’s back on track.

Hit same issue running on linux in docker.

Adding --disable-gpu resolved this in my instance.

Chrome Version: HeadlessChrome/89.0.4389.90 with puppeteer ^8.0.0

Dockerfile:

...
echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
...
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
RUN npm install puppeteer

puppeteer.js

const browser = await puppeteer.launch({
      args: ['--disable-dev-shm-usage', '--disable-gpu'],
      executablePath: 'google-chrome-stable'
});

--disable-gpu also helped me. But actually in my case problem was with some dependencies. After I installed all dependencies from https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix I was able to remove the --disable-gpu option.

Hit same issue running on linux in docker.

Adding --disable-gpu resolved this in my instance.

Chrome Version: HeadlessChrome/89.0.4389.90 with puppeteer ^8.0.0

Dockerfile:

...
echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
...
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
RUN npm install puppeteer

puppeteer.js

const browser = await puppeteer.launch({
      args: ['--disable-dev-shm-usage', '--disable-gpu'],
      executablePath: 'google-chrome-stable'
});

I installed the latest npm package (1.2.0) and browser.newPage() freezes everytime after ~1k visited pages with the bundled chrome. Same with v. 1.1.1.

Locking puppeteer version to 1.1.1 solved my browser.newPage hang issue. I had the latest version (1.12.0) which seemed to be the problem. Also was using --single-process for both scenarios.

Chrome Shell: 67.0.3361.0.tar.gz

Same probleme HeadlessChrome/90.0.4427.0 with puppeteer ^8.0.0

freezing at 1.14.0, fixed by downgrading to 1.11.0

I’m also troubleshooting this behavior right now, also using Puppeteer 0.13.0, but running on an ARMv7 Raspberry Pi (Model B Pi 2) so I can’t use the x86_64 Chromium that comes with Puppeteer. As a workaround I followed these instructions from @jindongh in issue #550 and I can get some things to work, but not browser.newPage().

Edit: To clarify, Puppeteer v0.10.2 with the special chromium install instructions I mentioned above works for me on the Raspberry Pi, I’m just seeing if I can get 0.13.0 to work and this has been where I get stuck.

I removed the launch options:–single-process,it’s work.🤡

I have the same issue trying to run puppeteer in CircleCI and it’s clearly due to the new versions of puppeteer because it works like a charm if I lock the version to 1.0.0 in my package.json :

{
  "dependencies": {
    "puppeteer": "1.0.0"
  }
}

https://github.com/GoogleChrome/puppeteer/pull/2564 Seem to related to this bug If I using the full path it will work @laggingreflex

My version is v62. I resolved this issue by using puppeteer v0.10.x.

I had this same issue but when I had puppeteer download Chrome instead of using my own copy it worked. Give that a try.

Wasn’t working with my 62.0.3202.94 WIN64 it downloaded 62.0.3264.0