puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

chrome_crashpad_handler: --database is required Only On Docker

Open wilsonbredaneto opened this issue 2 months ago • 1 comments

Hey guys.

I have an app with dotnet 3.1 running on docker with alpine. On this app I've install PuppeteerSharp 17.

But, when I call the following command on docker I got this following error:

command await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, Args = new[] { "--no-sandbox", }, ExecutablePath = "/usr/bin/chromium-browser" });

Error: PuppeteerSharp.ProcessException: Failed to launch browser! chrome_crashpad_handler: --database is required\nTry 'chrome_crashpad_handler --help' for more information.\n[999:999:0508/140237.277460:ERROR:socket.cc(120)] recvmsg: Connection reset by peer (104)\n\n at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 84\n at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89\n at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 68\n at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 99

Here's my dockerfile:

      _#####################
      #PUPPETEER RECIPE
      #####################
      # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
      # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
      # installs, work.
      RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
      && echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
      && echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
      && echo "https://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories \
      && apk upgrade -U -a \
      && apk add \
      libstdc++ \
      chromium \
      harfbuzz \
      nss \
      freetype \
      ttf-freefont \
      font-noto-emoji \
      wqy-zenhei \
      && rm -rf /var/cache/* \
      && mkdir /var/cache/apk
      
      # Set an environment variable to use that Chrome.
      ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/chromium-browser"
      #####################
      #END PUPPETEER RECIPE
      #####################_

When I try to run my application on my computer, it works well.

Can you help me with that, pls?

wilsonbredaneto avatar May 08 '24 18:05 wilsonbredaneto

Try this in your docker file. It seems new puppeteer instructs chrome to keep its files somewhere where chrome can't access them. Telling chromium to use /tmp did the trick for me.

ENV XDG_CONFIG_HOME=/tmp/.chromium
ENV XDG_CACHE_HOME=/tmp/.chromium

https://github.com/puppeteer/puppeteer/issues/11023#issuecomment-1776247197

inwenis avatar May 13 '24 13:05 inwenis

Try this in your docker file. It seems new puppeteer instructs chrome to keep its files somewhere where chrome can't access them. Telling chromium to use /tmp did the trick for me.

ENV XDG_CONFIG_HOME=/tmp/.chromium
ENV XDG_CACHE_HOME=/tmp/.chromium

puppeteer/puppeteer#11023 (comment)

It works for me. Thanks @inwenis.

wilsonbredaneto avatar May 16 '24 17:05 wilsonbredaneto