Consecutive launch with `headless: false` and userDataDir fails
See original GitHub issueSteps 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?
- 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);
}
})();
- 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:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
BTW,
waitUntil: 'networkidle0'
in thepage.goto()
options fixes this issue.