将Penthouse与Cloud Run结合使用时,我偶尔会出现此错误:
[1031/055417.851741:ERROR:address_tracker_linux.cc(201)] Could not bind NETLINK socket: Permission denied (13)
[1031/055417.854819:ERROR:file_path_watcher_linux.cc(71)] Failed to read /proc/sys/fs/inotify/max_user_watches
Inconsistency detected by ld.so: ../elf/dl-tls.c: 481: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
不幸的是,这在一段时间后随机发生。当我重新部署它时,它可以工作,但是过一段时间后,它将对所有后续请求显示相同的错误。
由于它是随机发生的,所以我找不到解决此问题的方法。
代码如下:
module.exports = async (req, res) => {
const browserPromise = puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--window-size=1920,1200',
],
defaultViewport: {
width: 1920,
height: 1200,
},
});
const critical_css = await penthouse({
url: req.body.url,
cssString: req.body.css,
pageLoadSkipTimeout: 1000,
timeout: 30000,
puppeteer: {
getBrowser: () => browserPromise,
},
});
res.send(critical_css);
};
这是Dockerfile:
# https://hub.docker.com/_/node
FROM node:12-slim
# 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 apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& 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 -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./
# Install production dependencies.
RUN npm ci --only=production
# Copy local code to the container image.
COPY . ./
# Run the web service on container startup.
CMD [ "npm", "start" ]
我尝试将资源增加到2个vCPU和4GB内存。那没有帮助。
类似的问题: