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 never resolves when using `userDataDir`

See original GitHub issue

browser.newPage() never resolve when using userDataDir in launch options.

Strangely, it only works when using headless: false.

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.4
  • Platform / OS version: Windows 10
  • URLs (if applicable):
  • Node.js version: 10.0

What steps will reproduce the problem?

  const browser = await puppeteer.launch({
    // headless: false, // un-commenting this makes it works
    userDataDir: 'test-profile-dir',
  });
  await browser.newPage();
  // Never reaches here
  console.log('If this logs, it worked!');

Please include code that reproduces the issue.

https://github.com/laggingreflex/puppeteer-userDataDir-hang

What is the expected result?

browser.newPage() should resolve and above code should be able to reach console.log statement

What happens instead?

It doesn’t

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
laggingreflexcommented, May 17, 2018

It also seems to work when full path is provided: __dirname + '/test-profile-dir'

2reactions
derekylecommented, Sep 28, 2019

Just for anyone’s reference, this issue still presents itself in version 1.20.0. When headless = true, then you must provide a full path instead of a relative one for userDataDir. In the case of headless = false, it works fine with both full and relative paths.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer: browser.newPage is not a function - Stack Overflow
Someone on Guilded helped me resolve this with a pretty simple fix. Basically both the puppeteer.launch({}); and browser.newPage(); return a ...
Read more >
puppeteer-core@19.4.1 - jsDocs.io
A promise that resolves to true if the revision could be downloaded from the host. Remarks. This method is affected by the current...
Read more >
node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
The Browser class extends from Puppeteer's {@link EventEmitter} class and will ... @returns Promise which resolves to the first target found.
Read more >
How to use the puppeteer.launch function in puppeteer - Snyk
launch(); const page = await browser.newPage(); // Catch + "forward" hashchange events from page to node puppeteer. await page.exposeFunction('onHashChange' ...
Read more >
Web Scraping with a Headless Browser: A Puppeteer Tutorial
This method lets us run custom JavaScript code as if we were executing it in the DevTools console. Anything returned from that function...
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