admin管理员组

文章数量:1357141

I recently upgraded node-html-to-image npm to 5.0.0 and subsequently installs puppeteer v22. I noticed my render time substantially increased from 3 seconds to 15 seconds. I run the service as an AWS Fargate ECS (ubuntu). Here is my Dockerfile:

FROM node:slim

# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
  wget --quiet --output-document=- .pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
  sh -c 'echo "deb [arch=amd64] / stable main" >> /etc/apt/sources.list.d/google.list' && \
  apt-get update && \
  apt-get install google-chrome-stable -y --no-install-recommends && \
  rm -rf /var/lib/apt/lists/*

  # Bundle app source
COPY . $HOME_DIR

# Clean up dev files
RUN rm -fr node_modules/*

# install app dependencies
RUN npm install

CMD npm start

I have looked at the puppeteer options and see nothing to reduce the render time since it appears that node-html-to-image sets the headless:shell mode for puppeteer.

Here is the invocation via node-html-to-image:

  await nodeHtmlToImage({
    output: pngName,
    html: Html,
    puppeteerArgs: {
      executablePath: '/usr/bin/google-chrome-stable',
      headless: 'shell',
      args: ['--no-sandbox'],
    },
    content: { imageGov: dataURI }
  })

I rolled back to version 2.1.1 of node-html-to-image which installs v2.1.1 of Puppeteer. That combination renders in 3 seconds. v3.0.0 of node-html-to-image uses v15 of Puppeteer and that is where the 5x slowdown occurs

本文标签: Puppeteer v22 much slower than v2Stack Overflow