Performance degradation after updating to newer Puppeteer version

I’m experiencing a major performance issue after upgrading my dependencies. When I updated the html-to-png library to version 5.0.0, it brought in Puppeteer v22 and my image generation time jumped from 3 seconds to 15 seconds. This is running on AWS Fargate with Ubuntu.

My Docker setup looks like this:

FROM node:slim

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

RUN apt-get update && apt-get install gnupg wget -y && \
  wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
  sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ 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/*

COPY . $HOME_DIR
RUN rm -fr node_modules/*
RUN npm install
CMD npm start

I’m calling it like this:

await htmlToPngConverter({
  output: outputFileName,
  html: htmlContent,
  puppeteerArgs: {
    executablePath: '/usr/bin/google-chrome-stable',
    headless: 'shell',
    args: ['--no-sandbox'],
  },
  content: { imageData: base64URI }
})

When I downgrade to version 2.1.1 of the html library (which uses Puppeteer v2.1.1), everything runs fast again at 3 seconds. The slowdown started happening with version 3.0.0 which uses Puppeteer v15. Has anyone else noticed this performance drop with newer Puppeteer versions?

Yeah, this is a known issue with Puppeteer versions after v13. Chromium changed how it handles resource allocation and process management in containers, which kills performance. I hit the same wall migrating from v10 to v19 last year. What worked for me was pinning Puppeteer to v13.7.0 in package.json - you still get security patches but dodge the performance hit. You can force html-to-png to use the older version by installing Puppeteer separately and setting the PUPPETEER_EXECUTABLE_PATH environment variable. Also check your Fargate CPU allocation. Newer versions eat more CPU during page initialization, so try bumping from 0.25 to 0.5 vCPU if you can’t pin the version.

totally feel you on this! i also noticed slowz after updat. try adding --disable-dev-shm-usage and --disable-extensions in puppeteer args, it helped me out. also, make sure your fargate task has enuf memory, seems like it’s hitting resource limits more often.

Had the same problem upgrading Puppeteer in production. Newer versions handle memory and processes differently, which hits containerized deployments hard. What fixed it for me: set a specific browser pool size and reuse browser instances instead of spawning new ones each time. Also check if you’re using the new headless mode - switch back to headless: true instead of headless: 'shell'. The shell mode has extra overhead that’ll slow things down. One more thing - v22 has tighter security defaults that might mess with your base64 image processing.