puppeteer: Atempt to open a page with `headless: true` and userDataDir relative path hangs with high CPU load

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.9.0-post (chromium_revision 599821)
  • Platform / OS version: Windows 7 x64
  • URLs (if applicable): any?
  • Node.js version: 11.0.0 (or 12.0.0-v8-canary)

What steps will reproduce the problem?

This script is OK:

'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({
      headless: true,
    });
    const [page] = await browser.pages();

    await page.goto('https://example.org/');

    console.log(await page.evaluate(() => document.title));

    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

This hangs with high CPU load and no error messages:

'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({
      headless: true,
      userDataDir: 'test-profile-dir',
    });
    const [page] = await browser.pages();

    await page.goto('https://example.org/');

    console.log(await page.evaluate(() => document.title));

    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Can’t launch just call resolve on userDataDir? Just wondered why my script that ran under macOS didn’t do anything under Windows… Disabled headless and it worked. Then found this. Hangs on navigation: { userDataDir: 'user_data', headless: true }. Workaround: { userDataDir: resolve('user_data'), headless: true }.

I have the same problem when i set userDataDir,Very high CPU consumption

@vsemozhetbyt this is a chromium bug, can you please report upstream?

Additional note: on Windows, / delimiter in the absolute user data dir path still causes this issue, only \\ delimiter is OK.

ok, with a relative dir I have the same issue you describe.

using the following code:

( async function main() {
	try {

		console.log( "about to pptr.launch()" );

		const browser = await puppeteer.launch( {
			headless: true,
			userDataDir: '..\\somedir',
		} );

		console.log( "done launch, about to obtain pages()" );

		const [ page ] = await browser.pages();

		console.log( "about to create new context+page" );

		console.log( "about to page.goto()" );

		await page.goto( 'https://example.org/' );
		console.log( "done to page.goto()" );

		console.log( await page.evaluate( () => document.title ) );

		await browser.close();
	} catch ( err ) {
		console.error( err );
	}
} )();

pptr hangs with max cpu at the await browser.pages(); call.

@jasonswearingen Thank you! It seems the cause is the path: try to use not absolute, but a relative path, i.e not 'c:\\tmp\\pptr' but just 'pptr'.

you are right, looking at my node_modules ppuppeteer package.json file, I’m using "chromium_revision": "594312"

if you can tell me what version to upgrade my puppeteer npm module to, I can give that a try. I"m on 1.9.0

Notes:

  1. It seems any URL will do (including https://example.org/).
  2. With headless: false the issue is gone.
  3. The content of the newly created profile dir after the process aborted:
Crashpad/reports
Crashpad/settings.dat
CrashpadMetrics-active.pma

P.S. 4. Absolute path for userDataDir is OK.