Error: Could not find Chrome (ver. 112.0.5615.121).
Mazuh opened this issue ยท 18 comments
Folks, any ideas? I already cleared Heroku build cache as instructed in the README file. And I'm running this via Heroku Scheduler. But I keep receiving an error like:
Error: Could not find Chrome (ver. 112.0.5615.121).
Here is some evidence...
From package.json:
"puppeteer": "^20.0.0",
"puppeteer-extra": "^3.3.6",
Here's my launch:
const { executablePath: puppeteerExecutablePath } = require("puppeteer");
const puppeteer = require("puppeteer-extra");
// ...
puppeteer.launch({
{ headless: true },
args: [
"--disable-gpu",
"--disable-dev-shm-usage",
"--disable-setuid-sandbox",
"--no-sandbox",
"--single-process",
"--incognito",
"--no-zygote",
],
executablePath: puppeteerExecutablePath(),
});
And the error:
2023-05-08T15:03:15.998557+00:00 app[scheduler.2244]: Error: Could not find Chrome (ver. 112.0.5615.121). This can occur if either
2023-05-08T15:03:15.998557+00:00 app[scheduler.2244]: 1. you did not perform an installation before running the script (e.g. `npm install`) or
2023-05-08T15:03:15.998557+00:00 app[scheduler.2244]: 2. your cache path is incorrectly configured (which is: /app/.cache/puppeteer).
2023-05-08T15:03:15.998559+00:00 app[scheduler.2244]: For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
2023-05-08T15:03:15.998560+00:00 app[scheduler.2244]: at ChromeLauncher.resolveExecutablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:301:27)
2023-05-08T15:03:15.998575+00:00 app[scheduler.2244]: at ChromeLauncher.executablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:183:25)
2023-05-08T15:03:15.998575+00:00 app[scheduler.2244]: at PuppeteerNode.executablePath (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/PuppeteerNode.js:155:105)
2023-05-08T15:03:15.998575+00:00 app[scheduler.2244]: at launchBrowser (/app/seeker/scraper.js:130:25)
2023-05-08T15:03:15.998576+00:00 app[scheduler.2244]: at /app/seeker/scraper.js:35:15
2023-05-08T15:03:15.998577+00:00 app[scheduler.2244]: at promiseResultMonad (/app/seeker/scraper-fp-helpers.js:41:12)
2023-05-08T15:03:15.998577+00:00 app[scheduler.2244]: at scrapProcessesData (/app/seeker/scraper.js:34:61)
2023-05-08T15:03:15.998577+00:00 app[scheduler.2244]: at /app/seeker/index.js:50:9
2023-05-08T15:03:15.998577+00:00 app[scheduler.2244]: at processTicksAndRejections (node:internal/process/task_queues:96:5)
2023-05-08T15:03:15.998578+00:00 app[scheduler.2244]: }
Well, the browser was indeed missing, so I created a bash script to fix it:
#!/bin/bash
echo 'Preparing to run automation on production mode.'
puppeteer_cache_dir=".cache/puppeteer/chrome/"
puppeteer_dep_dir="node_modules/puppeteer/"
if [[ -d "$puppeteer_cache_dir" ]];
then
echo "$puppeteer_cache_dir directory exists."
else
echo "$puppeteer_cache_dir directory does not exist. Trying to re-install Puppeteer."
cd "$puppeteer_dep_dir"
npm install
fi
echo "Going back to original directory and running script now..."
cd
npm run my_puppeteer_routine_here
But I wonder if I'm re-downloading something that already exists, it seems like a dumb use of resources. Any comments?
Well, the browser was indeed missing, so I created a bash script to fix it
@Mazuh Thanks very much for this script
I have this exact same issue on heroku-22
using buildback https://github.com/jontewks/puppeteer-heroku-buildpack
and using heroku ps:exec
to remote into our dyno, had no .cache
folder at all in my app directory so I cd node_modules/puppeteer/
and ran npm install
as per your script.
It appears that the current version is not installing chrome for some reason.
I also tried the README
solution of clearing the build cache before all this and it didn't make a difference in the error message
Looks like in puppeteer@18
it's got some new caching mechanics with chrome
We unfortunately had to downgrade our app's use of puppeteer to version 13 in order to avoid this issue. That's the best we were able to come up with for now. Even tried a postinstall
script in our package.json
but for some reason when you remote into your dyno the .cache
folder is nowhere to be found.
Also note that with additonal steps like this performed directly on the dyno your manual changes might be shaken off due to its ephemeral-filesystem
which specific version of puppeteer did you revert it to @ironicbrew ?
@CoolTechYT We went back to 13.7.0
but that just happens to be our previous version not a hard cutoff for when this issue occurs. You'd likely be able to upgrade as far as 16
and be fine but we haven't yet experimented that far with it to determine exactly where this issue appears yet.
I was able to get it working using 18.2.1
. Now the problem I have is that my slug is 499.2 megs lol.
buildpack: https://github.com/jontewks/puppeteer-heroku-buildpack#22.0.0
package.json: "puppeteer": "18"
499.2 megs lol.
Less than 500MB
? Ship it! lol
We ended up with the same issue on ~18
, although our slug was >600MB
. Too juicy for Heroku ๐ข.
Side effect of chromium balooning in size I believe
Edit: Ah no wait that's a really old issue that's since been fixed. Maybe it's occured again though?
Got it, I think the last working version (is there an acronym for this? I can't remember) is 18.1.0
Figured it out. Newer versions of puppeteer
require a different buildpack (https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/google-chrome.tgz
) in order to work on heroku
Stackoverflow post for slug size issue that solved it for me
@ironicbrew so we should use the AWS hosted buildpack instead of this repo?
@ironicbrew so we should use the AWS hosted buildpack instead of this repo?
Depends on the version of puppeteer you want to use, I'm performing regression testing now to figure out what versions the newer buildpack works for and I'll put together a PR that'll update the README for this repo
I took a look at the source code of https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/google-chrome.tgz
It's exactly the same as what you get from https://github.com/heroku/heroku-buildpack-google-chrome
, not sure why the stack overflow answer author would have used that url instead of the one you get from the official heroku buildpack registry but it works the same and using the official url instead is likely best practice.
Regression testing complete, this buildpack only works up to puppeteer ~18
. On >=19
you're going to get the error that kicked off this issue originally.
The new buildpack using the official url https://github.com/heroku/heroku-buildpack-google-chrome
is working for me on all puppeteer versions 13
- 20
although you must follow all the instructions.
@ironicbrew Thank you! That worked for me ๐
Thanks for all this info y'all.
If you're running into heroku slug size issues, you can use the no xdg-utils version of the buildpack which saves you a lot of space, but excludes one dependency. So far I've only heard of that causing an issue with PDF creation, but not sure what else that library is used for, but can be worth a shot.
I'll peruse the new google chrome buildpack and see if there are changes I can pull in to resolve. That previously was causing an issue with size as puppeteer installs its own version of chrome as well. @ironicbrew are you removing this current buildpack and only adding the new chrome and its working? Whats the slug size like?
Edit: I see the env variables in that link now, that makes sense.
Its interesting that this is working since the packages installed by the google chrome buildpack don't include several that puppeteer specifically call out as required. I also recall running into an issue where puppeteer expected the bundled version of chromium when trying to use the buildpack installed one as they are different. Their list is here: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-doesnt-launch-on-linux
Glad its working but there might be some issues that pop up in the future due to those things. I'll update the buildpack for whatever the issue is for puppeteer 20 though.
@ironicbrew are you removing this current buildpack and only adding the new chrome and its working? Whats the slug size like?
Removed puppeteer-heroku-buildpack
and am using heroku-buildpack-google-chrome
instead for a total slug size of 236 MiB
(compared to 500Mib - 600Mib
using your buildpack).
the packages installed by the google chrome buildpack don't include several that puppeteer specifically call out as required.
We're using a rather narrow set of puppeteer features so maybe that's why we're getting away with it?
I'm hoping that puppeteer just haven't updated that list in a while. Plus if xdg-utils is just pushing the whole thing over the total nowadays that chromium has become larger, there really is just no use.
I matched the packages installed by the official chrome buildpack and its working once again. I'll be updating the readme with one postbuild command that needs to be run on heroku since the puppeteer installation of chrome is not bundled with the app due to a name collision otherwise I believe.