Skip to content

Commit

Permalink
fix(ssr-tests-v9): don't open browser twice on CI to potentially miti…
Browse files Browse the repository at this point in the history
…gate TIMEOUT issues (#26587)
  • Loading branch information
Hotell authored Feb 1, 2023
1 parent 0ac9dc5 commit 91d91af
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions apps/ssr-tests-v9/src/utils/getChromeVersion.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import { isCI } from 'ci-info';
import { launchBrowser } from './launchBrowser';

/**
* https://github.com/puppeteer/puppeteer/blob/main/versions.js
*/
const CHROMIUM_VERSION = 'HeadlessChrome/110.0.5479.0';
const staticVersion = normalizeChromiumVersion(CHROMIUM_VERSION);

export async function getChromeVersion(): Promise<number> {
// this is a temporary solution to test if lanunching browser only once will mitigate TIMEOUT ISSUES ON CI
if (isCI) {
return staticVersion;
}

const browser = await launchBrowser();
const version = normalizeChromiumVersion(await browser.version());
await browser.close();

// includes browser name, example: HeadlessChrome/103.0.5058.0
const rawVersion = await browser.version();
const version = rawVersion.split('/')[1].split('.')[0];
if (version !== staticVersion) {
throw new Error(
`puppeteer uses different Chromium version!
puppeteer: ${version} , chromium_version constant: ${staticVersion}
await browser.close();
Please update CHROMIUM_VERSION constant to match puppeteer installed version https://github.com/puppeteer/puppeteer/blob/main/versions.js.`,
);
}

return version;
}

return parseInt(version, 10);
/**
*
* @param value - includes browser name, example: HeadlessChrome/103.0.5058.0
* @returns
*/
function normalizeChromiumVersion(value: string) {
return Number(value.split('/')[1].split('.')[0]);
}

0 comments on commit 91d91af

Please sign in to comment.