Skip to content

Commit

Permalink
fix(launcher): support relative userDataDir on headless Windows (#6506)
Browse files Browse the repository at this point in the history
Launching headless with a relative `userDataDir` hangs on Windows. Fix by calling `path.resolve` (idempotent) to add an absolute path instead in `defaultArgs`.

Issues: #3453
  • Loading branch information
vogler authored Oct 13, 2020
1 parent 8fabe32 commit f3086d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/node/Launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class ChromeLauncher implements ProductLauncher {
args = [],
userDataDir = null,
} = options;
if (userDataDir) chromeArguments.push(`--user-data-dir=${userDataDir}`);
if (userDataDir)
chromeArguments.push(`--user-data-dir=${path.resolve(userDataDir)}`);
if (devtools) chromeArguments.push('--auto-open-devtools-for-tabs');
if (headless) {
chromeArguments.push('--headless', '--hide-scrollbars', '--mute-audio');
Expand Down
4 changes: 2 additions & 2 deletions test/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe('Launcher specs', function () {
'--headless'
);
expect(puppeteer.defaultArgs({ userDataDir: 'foo' })).toContain(
'--user-data-dir=foo'
`--user-data-dir=${path.resolve('foo')}`
);
} else if (isFirefox) {
expect(puppeteer.defaultArgs()).toContain('--headless');
Expand All @@ -330,7 +330,7 @@ describe('Launcher specs', function () {
'-profile'
);
expect(puppeteer.defaultArgs({ userDataDir: 'foo' })).toContain(
'foo'
path.resolve('foo')
);
}
});
Expand Down

0 comments on commit f3086d7

Please sign in to comment.