@@ -28,16 +28,21 @@ export const runLighthouse = async (url, settings) => {
28
28
try {
29
29
console . log ( 'Launching Chrome with puppeteer...' ) ;
30
30
31
+ // Set cache directory before any Puppeteer operations
32
+ process . env . PUPPETEER_CACHE_DIR = '/tmp/puppeteer' ;
33
+ console . log ( 'Setting Puppeteer cache directory:' , process . env . PUPPETEER_CACHE_DIR ) ;
34
+
31
35
try {
32
- // For newer Puppeteer versions, just log the install location
33
- const installDir = process . env . PUPPETEER_CACHE_DIR || '/tmp/puppeteer' ;
34
- console . log ( 'Puppeteer install directory:' , installDir ) ;
36
+ console . log ( 'Installing Chrome...' ) ;
37
+ await puppeteer . browsers ( ) . install ( ) ;
38
+ console . log ( 'Chrome installation complete' ) ;
35
39
} catch ( err ) {
36
- console . log ( 'Error getting Puppeteer info :' , err . message ) ;
40
+ console . log ( 'Error installing Chrome :' , err . message ) ;
37
41
}
38
42
39
43
// Check for Chrome in Netlify environment first
40
44
const chromePaths = [
45
+ '/opt/buildhome/.cache/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64/chrome' ,
41
46
'/opt/buildhome/.cache/puppeteer/chrome/linux-119.0.6045.105/chrome-linux64/chrome' ,
42
47
'/usr/bin/google-chrome' ,
43
48
'/usr/bin/chromium-browser'
@@ -78,16 +83,14 @@ export const runLighthouse = async (url, settings) => {
78
83
try {
79
84
const launchConfig = {
80
85
headless : 'new' ,
81
- ...( executablePath ? { executablePath } : { } ) ,
82
86
args : [
83
87
'--no-sandbox' ,
84
88
'--disable-gpu' ,
85
89
'--disable-dev-shm-usage' ,
86
90
'--disable-software-rasterizer' ,
87
91
'--disable-setuid-sandbox' ,
88
92
'--no-zygote'
89
- ] ,
90
- cacheDirectory
93
+ ]
91
94
} ;
92
95
93
96
console . log ( 'Launching browser with config:' , launchConfig ) ;
0 commit comments