Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant run puppetier in heroku #138

Open
noam-honig opened this issue Dec 2, 2024 · 3 comments
Open

Cant run puppetier in heroku #138

noam-honig opened this issue Dec 2, 2024 · 3 comments

Comments

@noam-honig
Copy link

Hi,

I'm reaching out to you, since you probably know more about it than support :)

I have an app that has been running for more than a year and worked great.
Lately, my deplyments failed with:

-----> Installing dependencies
       Installing node modules
ERROR: Build terminated for reason: Build Timeout Expired
-----> Timed out running buildpack Node.js
 !     Push failed

I reached out to heroku support and they told me to add the following environment flag:

PUPPETEER_SKIP_DOWNLOAD=true

They said that chrome is taking too long to download.

Did it in a test environment (lucky me) and it fails the heroku-postbuild action detailed in this repo readme:

remote:        > yedidia@0.0.0 heroku-postbuild
remote:        > mkdir ./.cache && mv /app/.cache/puppeteer ./.cache
remote:
remote: mv: cannot stat '/app/.cache/puppeteer': No such file or directory

Of course if I remove the postbuild - than the setup is complete but the puppetier functionality doesn't work.

I hope you can help me, looking forward to hearing from you

@mihaa1
Copy link

mihaa1 commented Dec 4, 2024

same issue

@noam-honig
Copy link
Author

noam-honig commented Dec 7, 2024

Eventually resolved it by: (based on https://www.browserless.io/blog/puppeteer-heroku)

  1. switching to puppeteer-core
  2. installing this pack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku-community/chrome-for-testing.tgz in the following order:
    image
  3. Removed the heroku post-bulid sript from the package.json
  4. Set executable path like this:
  const puppeteer = await import("puppeteer-core")
  const browser = await puppeteer.launch({
    headless: true,
    executablePath: "/app/.chrome-for-testing/chrome-linux64/chrome",
    args: ["--no-sandbox", "--disable-setuid-sandbox"],
  })

Let me know if you think this is vialble, and maybe update the readme?

@louiswdavis
Copy link

louiswdavis commented Dec 12, 2024

We also ran into this issue and the above solution worked for us, but we use Grover to use puppeteer so had to adjust step 4 to;

# config/initializers/grover.rb

Grover.configure do |config|
  if Rails.env.in?(['staging', 'production'])
    config.options = {
      executable_path: '/app/.chrome-for-testing/chrome-linux64/chrome',
      launch_args: ['--no-sandbox', '--disable-setuid-sandbox'],
    }
  else
    config.options = {
      executable_path: '/opt/homebrew/bin/chromium',
    }
  end
end

We also tried moving/keeping puppeteer in our devDependencies in package.json so that it downloads chrome for us since the buildpack won't be doing that for us locally, but Heroku installs those for you too unless you turn off some config so we ended up just finding out local chromium path and using that for those ENVs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants