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)
Links to this issue
Commits related to this issue
- fix for Windows: hangs if userDataDir is relative path and launched headless https://github.com/GoogleChrome/puppeteer/issues/3453 — committed to vogler/syncmine by vogler 5 years ago
- fix(launcher): also support relative userDataDir on headless Windows Launching headless with a relative `userDataDir` hangs on Windows. Fix by calling `path.resolve` (idempotent) to add an absolute p... — committed to vogler/puppeteer by vogler 4 years ago
- fix(launcher): support relative userDataDir on headless Windows (#6506) Launching headless with a relative `userDataDir` hangs on Windows. Fix by calling `path.resolve` (idempotent) to add an absolut... — committed to puppeteer/puppeteer by vogler 4 years ago
- fix process stderr handle — committed to rust-headless-chrome/rust-headless-chrome by deleted user 3 years ago
Can’t
launch
just callresolve
onuserDataDir
? 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
Done: https://bugs.chromium.org/p/chromium/issues/detail?id=900952
@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:
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:
headless: false
the issue is gone.P.S. 4. Absolute path for
userDataDir
is OK.