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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:50 (6 by maintainers)

github_iconTop GitHub Comments

12reactions
zialecommented, Aug 26, 2020

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?

10reactions
oliviertassinaricommented, Jan 13, 2019

@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.' }
Read more comments on GitHub >

github_iconTop Results From Across the Web

browser.newPage freezes (never resolves) #4039 - GitHub
Sometimes Chrome will freeze on browser. newPage on the older version of puppeteer. puppeteer/puppeteer#4039 Also required upgrading the ...
Read more >
Puppeteer browser.newPage() hangs - node.js - Stack Overflow
I am using NodeJS Puppeteer in Kubernetes. However, running page = await browser. newPage(); did not get the result. Since I have timeInterval ......
Read more >
Puppeteer browser hanged on newPage() on Web App ...
It works in the beginning but hanged on browser. newPage() after idle and no new trace awhile.
Read more >
1198567 - Headless browser freezes on Windows unless ...
Issue 1198567: Headless browser freezes on Windows unless launched with '--disable-gpu' ... newPage()` step after r870496 when not using `--disable-gpu`.
Read more >
Puppeteer documentation - DevDocs
Puppeteer communicates with the browser using DevTools Protocol. Browser instance can own ... newPage() creates a page in the default browser context.
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