Puppeteer Zombie Process Solution

Mainly, I observed that the child process is not being killed or terminated by the parent process in the operating system, causing it to become a zombie process. So, obviously, the issue could be related to either the Puppeteer library or the operating system you are using, or even the browser.

Additionally, I tried to replicate the issue on my local machine by running a Node server, but the issue did not occur. However, when I set up a Docker environment locally and deployed pods via Minikube, I successfully replicated the issue.

I then attempted to resolve the issue by updating the Puppeteer library to the latest version, but the problem persisted, although the number of zombie processes decreased from 6 to 4.

Subsequently, I decided to switch the operating system to Linux and use the Chrome browser, which led to success. This indicates that the zombie process issue is not caused by the Puppeteer library, but rather by the operating system. Previously, I was using the Alpine OS, but now I am using the Linux slim OS.

I also switched to using the stable version of the Google Chrome browser.

FROM node:18-slim
RUN apt-get update
RUN apt-get upgrade

RUN apt-get update && apt-get install curl gnupg -y
&& curl --location --silent dl-ssl.google.com/linux/linux_sign... | apt-key add -
&& sh -c 'echo "deb [arch=amd64] 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/*

RUN apt-get update &&
apt-get upgrade && apt-get install -y vim

ADD ./puppetron.tar /usr/share/
WORKDIR /usr/share/puppetron

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV SERVICE_PATH=/usr/share/puppetron

CMD node main.js;

I have thoroughly reviewed the documentation and exhausted all available solutions in an attempt to resolve the zombie process issue. Despite my efforts, the problem persisted. I attempted to terminate process IDs, but within the pods, the zombie processes remained resilient. Devoting several consecutive days to diligently updating every package eventually proved successful. The issue was ultimately resolved by making key adjustments: switching the operating system from Node Alpine to Node Slim Linux and transitioning from Chromium to Chrome as the browser. The specific changes implemented to rectify the problem are outlined below.

If you are working with Puppeteer and encountering zombie process issues, consider employing the following Docker commands. These commands have proven effective in preventing the creation of zombie processes.

#Path of browser change to
executablePath: '/usr/bin/google-chrome',

Related Posts

Leave a Reply

Your email address will not be published.