Puppeteer unable to run on heroku

前端 未结 2 1837
孤独总比滥情好
孤独总比滥情好 2020-12-28 17:50

I deployed an app on heroku, and i added the puppeteer Heroku buildpack.

After a succesful redeployment, i try to run it and it fails. Using heroku logs -t

相关标签:
2条回答
  • 2020-12-28 18:18

    You should be able to solve this issue by passing the --no-sandbox and --disable-setuid-sandbox flags to puppeteer.launch():

    const browser = await puppeteer.launch({
      args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
      ],
    });
    

    If this does not work, you may want to read the official Puppeteer troubleshooting guide: Running Puppeteer on Heroku.

    0 讨论(0)
  • 2020-12-28 18:27

    Here is what worked for me. First, I clear all my buildpacks and then I added the puppeteer-heroku-buildpack and the heroku/nodejs one:

    $ heroku buildpacks:clear
    $ heroku buildpacks:add --index 1 https://github.com/jontewks/puppeteer-heroku-buildpack
    $ heroku buildpacks:add --index 1 heroku/nodejs
    

    Then, add the following args to the puppeteer launch function:

    const browser = await puppeteer.launch({
      'args' : [
        '--no-sandbox',
        '--disable-setuid-sandbox'
      ]
    });
    

    Finally, deploy it back to Heroku:

    $ git add .
    $ git commit -m "Fixing deployment issue"
    $ git push heroku master
    
    0 讨论(0)
提交回复
热议问题