From d8e3c7d9a32c8d89401210274a26a12a1ddaa0e0 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 2 Mar 2026 13:28:31 +0100 Subject: [PATCH] fix(ci): improve chrome detection and debug logging for lighthouse --- scripts/pagespeed-sitemap.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/pagespeed-sitemap.ts b/scripts/pagespeed-sitemap.ts index 5c6b8e68..8465061c 100644 --- a/scripts/pagespeed-sitemap.ts +++ b/scripts/pagespeed-sitemap.ts @@ -84,17 +84,21 @@ async function main() { let chromePath = process.env.CHROME_PATH || process.env.PUPPETEER_EXECUTABLE_PATH; if (!chromePath) { try { + console.log('🔍 Attempting to detect Puppeteer Chrome path...'); const puppeteerInfo = execSync('npx puppeteer browsers latest chrome', { encoding: 'utf8', }); + console.log(`đŸ“Ļ Puppeteer info: ${puppeteerInfo}`); const match = puppeteerInfo.match(/executablePath: (.*)/); if (match && match[1]) { chromePath = match[1].trim(); - console.log(`🔍 Detected Puppeteer Chrome at: ${chromePath}`); + console.log(`✅ Detected Puppeteer Chrome at: ${chromePath}`); } - } catch (e) { - console.warn('âš ī¸ Could not detect Puppeteer Chrome path automatically.'); + } catch (e: any) { + console.warn(`âš ī¸ Could not detect Puppeteer Chrome path automatically: ${e.message}`); } + } else { + console.log(`â„šī¸ Using existing Chrome path: ${chromePath}`); } const chromePathArg = chromePath ? `--collect.chromePath="${chromePath}"` : ''; @@ -106,9 +110,9 @@ async function main() { // Using a more robust way to execute and capture output // We remove 'npx lhci upload' to keep everything local and avoid Google-hosted reports - const lhciCommand = `CHROME_PATH="${chromePath}" npx lhci collect ${urlArgs} ${chromePathArg} --config=config/lighthouserc.json --collect.settings.extraHeaders='${extraHeaders}' --collect.settings.chromeFlags="--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage" && npx lhci assert --config=config/lighthouserc.json`; + const lhciCommand = `npx lhci collect ${urlArgs} ${chromePathArg} --config=config/lighthouserc.json --collect.settings.extraHeaders='${extraHeaders}' --collect.settings.chromeFlags="--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage" && npx lhci assert --config=config/lighthouserc.json`; - console.log(`đŸ’ģ Executing LHCI...`); + console.log(`đŸ’ģ Executing LHCI with CHROME_PATH="${chromePath}"...`); try { execSync(lhciCommand, {