Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser.newPage freezes #1409

Closed
sylvainlap opened this issue Nov 17, 2017 · 51 comments
Closed

browser.newPage freezes #1409

sylvainlap opened this issue Nov 17, 2017 · 51 comments

Comments

@sylvainlap
Copy link

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
@xori
Copy link

xori commented Nov 17, 2017

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

@jmg1138
Copy link

jmg1138 commented Nov 20, 2017

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.

@aslushnikov
Copy link
Contributor

@sylvainlap this looks like an old version of chrome. What's the version of the chromium you run?

@sylvainlap
Copy link
Author

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

@loliconer
Copy link

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

@aslushnikov
Copy link
Contributor

aslushnikov commented Nov 22, 2017

The new version of puppeteer is guaranteed to work with the bundled chromium, no other guarantees are made yet. We'll be forward-compatible with chrome versions once the underlying devtools protocol is brought out of experiment.

@koloritcm
Copy link

@aslushnikov I'm using puppeteer-heroku-buildpack on Heroku with Puppeteer 0.13.0, so I guess Puppeteer downloads its bundled Chromium version. I get random freezes at:

const page = await browser.newPage();.

So this issue should be opened again as the bug seems to happen on current Puppeteer with its bundled chromium? Any suggested temporary solution at this time?

@JohnHanna86
Copy link

I installed the latest puppeteer npm package (0.13.0) and it has the same problem with the bundled Chromium.

@v1nc
Copy link

v1nc commented Mar 22, 2018

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.

@laggingreflex
Copy link

laggingreflex commented May 12, 2018

Same issue, but in my case it's only working with headless: false.

puppeteer v1.4, chromium version downloaded: win64-555668

Edit: Opened an issue: #2538

@bebeo92
Copy link

bebeo92 commented May 21, 2018

@laggingreflex I facing the same issue is there any news?

@bebeo92
Copy link

bebeo92 commented May 21, 2018

#2564
Seem to related to this bug
If I using the full path it will work
@laggingreflex

@kenorbi
Copy link

kenorbi commented Jun 12, 2018

same here on lambda, stops at
await browser.newPage();

using latest version

puppeteer 1.5.0 with HeadlessChrome/69.0.3452.0

@mismith
Copy link

mismith commented Jul 10, 2018

I'm also seeing this issue consistently when puppeteer's HeadlessChrome version (69.0.3452.0) doesn't match the version of Chrome installed on the Windows 2008 RC2 machine (67.0.3396.99)

@VinayParasrampuria
Copy link

I/m facing the same issue with puppeteer 1.6.2 and chrome 69.0.3497.100

@joscul
Copy link

joscul commented Oct 15, 2018

I am facing the same issue with puppeteer 1.9 and chrome 71.0.3563.0 (r594312) on linux.

Does anyone have a workaround?

@JohanG2012
Copy link

JohanG2012 commented Oct 18, 2018

Same issue for me as well... Happens after opening around 1000 pages.
puppeteer 1.9.0
Chrome Version 69.0.3497

Some more informations if it helps. I run Puppeter in an Node application inside of a docker container localy. And when Puppeter get stuck. Chrome on my desktop also stops working (pages crashes at the same time I open them). When I restart the docker container/node application then Chrome on my desktop starts working just fine again.

Maybe this is an issue with Chrome and not with Puppeteer itself?

@AE9RB
Copy link

AE9RB commented Oct 23, 2018

Puppeteer 1.8 and 1.9 tested using bundled chromium. The ws connection is unstable and goes down. "Error: Protocol error (Runtime.callFunctionOn): Target closed." No problem, I just set it up again. However, any browser.newPage promises that were pending are now stuck.

@lukeAnderson2015
Copy link

lukeAnderson2015 commented Nov 8, 2018

Same issue, using:

Puppeteer 1.10.0
Chrome/72.0.3582.0

I'm trying to run this in CircleCI via a node script

{ 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.' }

@sookinoby2
Copy link

Same issue, using:

Puppeteer 1.10.0
Chrome/72.0.3582.0
OS: Linux (Jenkins CI)
When I run in local (mac-os), everything looks fine

@aslushnikov
Copy link
Contributor

@lukeAnderson2015 @sookinoby2 if the browser.newPage fails for you with the target closed exception, then Chrome is having issues to run in your host environment.

It could be there's no enough memory, or host prohibits spawning child processes. In the latter case, try running with --single-process to try to narrow the scope.

Note: the --single-process mode is not generally supported, so I wouldn't run anything in production with this flag.

@JohanG2012
Copy link

hmm, this issue has existed for some time now, without any response at all... @sylvainlap could you perhaps reopen this issue?

@JohanG2012
Copy link

@aslushnikov I only open a page once every 3000 ms so it's not an issue with either memory or child processes 😕

@aslushnikov
Copy link
Contributor

@JohanG2012 feel free to file a new issue, but please include enough details so that we can reproduce it locally.

@JohanG2012
Copy link

@JohanG2012 feel free to file a new issue, but please include enough details so that we can reproduce it locally.

Will do as soon as I got time 👍

@Dammmien
Copy link

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"
  }
}

@bcowell
Copy link

bcowell commented Jan 9, 2019

Same issue trying to run Puppeteer 1.2.0 on a Windows Server 2016.
Trying version 1.0.0 like @Dammmien recommends didn't resolve my issue.
Sever just spawns a bunch of Chromium processes and becomes unresponsive.

@oliviertassinari
Copy link
Contributor

oliviertassinari commented 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.' }

dtinth added a commit to ycccamp/ycc2-landing that referenced this issue Jan 31, 2019
@millergd
Copy link

millergd commented Feb 5, 2019

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

@JouiiinO
Copy link

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

@mtford90
Copy link

Yep - 1.11.0 downgrade solved this for me too!

@pqvst
Copy link
Contributor

pqvst commented Feb 18, 2019

Also experiencing this issue with 1.12.2 (newPage hangs after a couple of hours). So should this issue be re-opened, has it been fixed, or is there a different issue for it? Unclear...

Edit: I've created a new issue: #4039

@vongohren
Copy link

I experienced this all the time and this comment explains how I solved it #1947 (comment)

@Xorbit17
Copy link

Xorbit17 commented Mar 1, 2019

1.11.0 downgrade saved me too. Running on a raspberry Pi model 3 with raspbian. Only puppeteer-core using chromium.

@Dkra
Copy link

Dkra commented Apr 19, 2019

1.14.0 froze as well, downgrade to 1.11.0 works.

@francocores
Copy link

francocores commented Apr 26, 2019

im work fine HeadlessChrome/67.0.3361.0 puppeter 1.11.0

@nodegin
Copy link

nodegin commented Jun 30, 2019

freezing at 1.14.0, fixed by downgrading to 1.11.0

@CorentinB
Copy link

Do you people know if any other version than 1.11.0 fix this issue? Considering the vulnerability in 1.11.0, it's not the best idea to use it.. 😞

@WillsB3
Copy link

WillsB3 commented Jul 31, 2019

I was also seeing this when launching Chrome Canary (Version 78.0.3870.0) via Puppeteer. This used to work for me but I guess Canary has been updated since then.

Switching to the bundled Chromium fixed the issue for me

@co3k
Copy link

co3k commented Aug 12, 2019

I've confirmed this issue on CircleCI environment with bundled Chrome since 89a5c39

@oO0oO0oO0o0o00
Copy link

Same with puppeteer@2.1.1.

  • With headless: hang
  • Without headless: ok
  • Headless & pipe: stucks earlier at puppeteer.launch

@francocores
Copy link

Same with puppeteer@2.1.1.

  • With headless: hang
  • Without headless: ok
  • Headless & pipe: stucks earlier at puppeteer.launch

Hi! Can you add fragment or example of your code?

@oO0oO0oO0o0o00
Copy link

oO0oO0oO0o0o00 commented Apr 15, 2020

Same with puppeteer@2.1.1.

  • With headless: hang
  • Without headless: ok
  • Headless & pipe: stucks earlier at puppeteer.launch

Hi! Can you add fragment or example of your code?

const puppeteer = require('puppeteer');
//......
async function xxx() {
	log(0)
	const browser = await puppeteer.launch({
		headless: false // Headless mode fails
	});
	log(1)
	const page = await browser.newPage();
	log(2) // Never reaching here if not setting headless to false
	await page.goto('https://xxx')
        // ......
}

@ziale
Copy link

ziale commented 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?

@towry
Copy link

towry commented Jan 25, 2021

See towry/n#148

@innovaweb-dev
Copy link

Same probleme HeadlessChrome/90.0.4427.0 with puppeteer ^8.0.0

@blockscoped
Copy link

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'
});

@xtix
Copy link

xtix commented Mar 23, 2021

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.

@2tuzi
Copy link

2tuzi commented Aug 23, 2021

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

Chrome Version: Chrome/92.0.4515.159 with puppeteer ^10.2.0

@Stormtv
Copy link

Stormtv commented Nov 24, 2021

Had this issue on alpine linux v3.14 and downgrading to alpine linux v3.13 fixed it. Not sure why but I'll look into it.

@surxme
Copy link

surxme commented Jan 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests