Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: robustly check for launch executable #8468

Merged
merged 1 commit into from Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/node/Launcher.ts
Expand Up @@ -71,8 +71,8 @@ class ChromeLauncher implements ProductLauncher {
ignoreDefaultArgs = false,
args = [],
dumpio = false,
channel = null,
executablePath = null,
channel,
executablePath,
pipe = false,
env = process.env,
handleSIGINT = true,
Expand All @@ -83,7 +83,7 @@ class ChromeLauncher implements ProductLauncher {
slowMo = 0,
timeout = 30000,
waitForInitialPage = true,
debuggingPort = null,
debuggingPort,
} = options;

const chromeArguments = [];
Expand All @@ -103,7 +103,7 @@ class ChromeLauncher implements ProductLauncher {
) {
if (pipe) {
assert(
debuggingPort === null,
!debuggingPort,
'Browser should be launched with either pipe or debugging port - not both.'
);
chromeArguments.push('--remote-debugging-pipe');
Expand Down Expand Up @@ -134,25 +134,22 @@ class ChromeLauncher implements ProductLauncher {
isTempUserDataDir = false;

let chromeExecutable = executablePath;

if (channel) {
// executablePath is detected by channel, so it should not be specified by user.
assert(
typeof executablePath === 'string',
jrandolf marked this conversation as resolved.
Show resolved Hide resolved
!chromeExecutable,
'`executablePath` must not be specified when `channel` is given.'
);

chromeExecutable = executablePathForChannel(channel);
} else if (!executablePath) {
} else if (!chromeExecutable) {
const { missingText, executablePath } = resolveExecutablePath(this);
if (missingText) throw new Error(missingText);
if (missingText) {
throw new Error(missingText);
}
chromeExecutable = executablePath;
}

if (!chromeExecutable) {
throw new Error('chromeExecutable is not found.');
}

const usePipe = chromeArguments.includes('--remote-debugging-pipe');
const runner = new BrowserRunner(
this.product,
Expand Down Expand Up @@ -183,7 +180,7 @@ class ChromeLauncher implements ProductLauncher {
[],
ignoreHTTPSErrors,
defaultViewport,
runner.proc ?? undefined,
runner.proc,
runner.close.bind(runner)
);
} catch (error) {
Expand Down Expand Up @@ -262,7 +259,8 @@ class ChromeLauncher implements ProductLauncher {
if (channel) {
return executablePathForChannel(channel);
} else {
return resolveExecutablePath(this).executablePath;
const results = resolveExecutablePath(this);
return results.executablePath;
}
}

Expand Down