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

Can't generate PDF on production #30

Open
diegoolavarria opened this issue Jan 6, 2020 · 3 comments
Open

Can't generate PDF on production #30

diegoolavarria opened this issue Jan 6, 2020 · 3 comments

Comments

@diegoolavarria
Copy link

diegoolavarria commented Jan 6, 2020

I deployed my Nodejs app on AWS EC2 running Linux/4.8.3. When trying to generate a pdf from HTML generated in the server (then I send the buffer to the browser), it shows a CORS policy error.

I tried sending {args: ['--no-sandbox']} as launch parameters with no success. pdfContent is my generate HTML code :

return new Promise((resolve, reject) => {
    const send = result => {
      resolve(result)
    }
    convertHTMLToPDF(pdfContent, result => send(result), {}, {args: ['--no-sandbox']})
  }
)

Server side, is showing me this:

image

Thank you!

@cr7boulos
Copy link
Collaborator

Thanks for posting. I'll take a look and follow up when I find any additional information.

@cr7boulos
Copy link
Collaborator

@diegoolavarria Sorry for the delay in responding to this. I did some digging and it is possible that your EC2 instance is missing some required dependencies. I would suggest taking a look at this link: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix

Run this command on your ECS2 instance at a shell prompt: ldd chrome | grep not to see if any dependencies are missing.

This link gives some details on setting up puppetteer in a headless environment:
https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#setting-up-chrome-linux-sandbox

@polkerty
Copy link

I also can't get Puppeteer to run on an ECS instance. I update my Dockerfile to follow the one in the repository: it starts

FROM buildkite/puppeteer:latest

ENV PATH="${PATH}:/usr/src/app/node_modules/.bin"

However, now I get the error

(node:1) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
[0716/154556.287986:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

Clearly pdf-puppeteer is passing the --no-sandbox flag internally, however.

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