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: only kill the browser process when it cannot be started but not when waiting on the first target #7762

Merged
merged 1 commit into from
Nov 11, 2021
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
34 changes: 26 additions & 8 deletions src/node/Launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,37 @@ class ChromeLauncher implements ProductLauncher {
pipe: usePipe,
});

let browser;
try {
const connection = await runner.setupConnection({
usePipe,
timeout,
slowMo,
preferredRevision: this._preferredRevision,
});
const browser = await Browser.create(
browser = await Browser.create(
connection,
[],
ignoreHTTPSErrors,
defaultViewport,
runner.proc,
runner.close.bind(runner)
);
if (waitForInitialPage)
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
return browser;
} catch (error) {
runner.kill();
throw error;
}

if (waitForInitialPage) {
try {
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
} catch (error) {
await browser.close();
throw error;
}
}

return browser;
}

defaultArgs(options: BrowserLaunchArgumentOptions = {}): string[] {
Expand Down Expand Up @@ -371,28 +380,37 @@ class FirefoxLauncher implements ProductLauncher {
pipe,
});

let browser;
try {
const connection = await runner.setupConnection({
usePipe: pipe,
timeout,
slowMo,
preferredRevision: this._preferredRevision,
});
const browser = await Browser.create(
browser = await Browser.create(
connection,
[],
ignoreHTTPSErrors,
defaultViewport,
runner.proc,
runner.close.bind(runner)
);
if (waitForInitialPage)
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
return browser;
} catch (error) {
runner.kill();
throw error;
}

if (waitForInitialPage) {
try {
await browser.waitForTarget((t) => t.type() === 'page', { timeout });
} catch (error) {
await browser.close();
throw error;
}
}

return browser;
}

executablePath(): string {
Expand Down