From 6440d893f084da1acf6eb799473d3ef599b2b7bd Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 2 Mar 2026 13:33:02 +0100 Subject: [PATCH] fix(ci): add hardcoded fallback for puppeteer chrome in lighthouse --- scripts/pagespeed-sitemap.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/pagespeed-sitemap.ts b/scripts/pagespeed-sitemap.ts index 8465061c..094db066 100644 --- a/scripts/pagespeed-sitemap.ts +++ b/scripts/pagespeed-sitemap.ts @@ -95,12 +95,41 @@ async function main() { console.log(`✅ Detected Puppeteer Chrome at: ${chromePath}`); } } catch (e: any) { - console.warn(`⚠️ Could not detect Puppeteer Chrome path automatically: ${e.message}`); + console.warn(`⚠️ Could not detect Puppeteer Chrome path via command: ${e.message}`); + } + + // Fallback to known paths if still not found + if (!chromePath) { + const fallbacks = [ + '/root/.cache/puppeteer/chrome/linux-145.0.7632.77/chrome-linux64/chrome', + '/home/runner/.cache/puppeteer/chrome/linux-145.0.7632.77/chrome-linux64/chrome', + path.join( + process.cwd(), + 'node_modules', + '.puppeteer', + 'chrome', + 'linux-145.0.7632.77', + 'chrome-linux64', + 'chrome', + ), + ]; + + for (const fallback of fallbacks) { + if (fs.existsSync(fallback)) { + chromePath = fallback; + console.log(`✅ Found Puppeteer Chrome at fallback: ${chromePath}`); + break; + } + } } } else { console.log(`ℹ️ Using existing Chrome path: ${chromePath}`); } + if (!chromePath) { + console.warn('❌ CHROME_PATH is still undefined. Lighthouse might fail.'); + } + const chromePathArg = chromePath ? `--collect.chromePath="${chromePath}"` : ''; // Clean up old reports