Error: Unable to launch browser for worker puppeteer
I am using the Unlighthouse tool to generate page speed reports. When I continuously generate multiple reports, at some point Puppeteer stops working. I am frustrated with trying numerous commands suggested by various bloggers, but none have fixed my issue.
My error:
.nvm/versions/node/v20.10.0/lib/node_modules/unlighthouse-ci/node_modules/puppeteer-cluster/dist/Cluster.js:146 throw new Error(`Unable to launch browser for worker, error message: ${err.message}`);
Error: Unable to launch browser for worker, error message: Failed to launch the browser process!
✅ Solution 1
After extensive research, I found that chromium browser won't launch for super(root) user.
✅ Solution 2
Error: Unable to launch browser for worker, error message: ENOSPC: no space left on device, mkdtemp '/tmp/puppeteer_dev_chrome_profile-AK3sgN'
This error indicate a storage issue.
The error message you're encountering indicates that the Puppeteer browser process failed to launch due to a lack of space on the device. Specifically, the error No space left on device (28) suggests that the /tmp directory is full. Puppeteer, which is used by unlighthouse-ci, relies on temporary storage to function, and it cannot proceed without sufficient space.
In this solution, I will show you how to clear the temporary directory on a Linux machine.
Check Disk Space:
Use the df -h command to check the available disk space, particularly in the /tmp directory.
df -h /tmp
Clean Up /tmp Directory:
Remove all files from the /tmp directory to free up space. You can list files in the /tmp directory with the ls -la /tmp command and remove them using the rm command.
ls -la /tmp sudo rm -rf /tmp/*
You still face the error even after removing all items in the tmp folder. This indicates that there is no space to store temporary files on your system. You can temporarily change the tmp folder to a location on a larger disk when you run the command.
export TMPDIR=/path/to/new/tmp