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.

Consecutive launch with `headless: false` and userDataDir fails

See original GitHub issue

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): https://twitter.com/
  • Node.js version: 11.0.0 (or 12.0.0-v8-canary)

What steps will reproduce the problem?

  1. Run this code, log in the Twitter account, close the browser.
'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({
      headless: false,
      userDataDir: 'test-profile-dir',
    });
    const [page] = await browser.pages();
    await page.goto('https://twitter.com/');
    console.log(await page.evaluate(() => document.title));
  } catch (err) {
    console.error(err);
  }
})();
  1. Run the same script the second time, See the error:
Error: Execution context was destroyed, most likely because of a navigation.
    at rewriteError (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\ExecutionContext.js:144:15)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
  -- ASYNC --
    at ExecutionContext.<anonymous> (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\helper.js:144:27)
    at ExecutionContext.evaluate (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\ExecutionContext.js:58:31)
    at ExecutionContext.<anonymous> (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\helper.js:145:23)
    at Frame.evaluate (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\FrameManager.js:439:20)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
  -- ASYNC --
    at Frame.<anonymous> (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\helper.js:144:27)
    at Page.evaluate (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\Page.js:728:43)
    at Page.<anonymous> (C:\Users\vmb\AppData\Roaming\npm\node_modules\puppeteer\lib\helper.js:145:23)
    at main (e:\DOC\prg\js\node\-test\test.js:17:28)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JoelEinbindercommented, Oct 29, 2018

you could try to use waitForSelector or waitForFunction to make sure the page is in a state you expect. If you wait a foolproof way of knowing when an arbitratary page is done navigating, that’s unfortunately unsolvable.

0reactions
vsemozhetbytcommented, Nov 2, 2018

BTW, waitUntil: 'networkidle0' in the page.goto() options fixes this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consecutive launch with `headless: false` and userDataDir fails
Run this code, log in the Twitter account, close the browser. 'use strict'; const puppeteer = require('puppeteer'); (async function main() { try ...
Read more >
how to use user-data-dir but for multiple puppeteer windows
The launch should look like this: const browser = await puppeteer.launch({ headless: false, args: [ ...
Read more >
Observations running more than 5 million headless sessions a ...
When running headless chrome, especially with puppeteer, ... Saw an error:', err); } finally { cleanup(userDataDir); } }; run();.
Read more >
Chrome --user-data-dir not working properly?
Point chrome shortcut to the NEW DIRECTORY using the --user-data-dir parameter 3. After launch, notice that the profile is exactly as the original....
Read more >
page.goto: navigation failed because page crashed - You.com
javascript const { chromium } = require("playwright"); (async () => { const browser = await chromium.launch({ headless: false }); //Crashes //const browser ...
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