puppeteer: [Bug]: Docker M1 Mac fails to open new page (`Target.createTarget`)
Bug description
const puppeteer = require('puppeteer');
(async function () {
const browser = await puppeteer.launch({
headless: true,
args: [
'--disable-gpu', // if i remove this, strangely the process exits unexpectedly
'--disable-dev-shm-usage',
'--no-sandbox',
'--disable-setuid-sandbox',
],
});
await browser.newPage();
})();
Dockerfile
FROM --platform=linux/amd64 node:16.13.1-slim
RUN apt-get update && \
apt-get -y install vim xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget python make g++
RUN rm -rf /var/lib/apt/lists/*
# todo: automate this version
RUN npm install --save puppeteer@13.5.1
COPY package*.json ./
RUN npm ci;
RUN mkdir -p /home/node/app && cp -a /tmp/node_modules /home/node/app/
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /home/node/app
RUN ./node_modules/typescript/bin/tsc -b --verbose
USER pptruser
Puppeteer version
13.5.1
Node.js version
16.13.1
npm version
8.3.0
What operating system are you seeing the problem on?
macOS (M1 Mac)
Relevant log output
ProtocolError: Protocol error (Target.createTarget): Target closed.
at /home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:75:24
at new Promise (<anonymous>)
at Connection.send (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:71:16)
at Browser._createPageInContext (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:261:53)
at BrowserContext.newPage (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:520:30)
at Browser.newPage (/home/node/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:254:37)
at /home/node/app/src/test.js:17:19
at processTicksAndRejections (node:internal/process/task_queues:96:5)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 28
- Comments: 20
I have the same issue running on M1 Pro. Node: Docker image node:16.15.0 Puppeteer: 14.3.0 Npm: 8.2.0
I was hoping that
PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM
will fix that as well, but it didn’t (at least for me). I still can’t open pages in pptr docker on my m1 macbook.I have the following error:
Are there any plans to address this issue soon ⛈️ ?
Not stale.
I also have this
Target closed
problem on M1 Macbook. Native (arm64) Nodev17.5.0
and puppeteerv13.4.1
.Happens at the 3rd
browser.newPage()
call.I managed to get it installed using PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM
and now I I can use the ExecuteJavascriptMiddleware Middleware of Roach, which uses Puppeteer but for some reason it doesn’t find the installed chrome.
Still trying to solve it!
It worked like a charm !! Thanks @LofoWalker , you saved me wasting another hours to shoot this bug.
Yeah sure :
I’ve fixed it by adding --single-process in the launch args just as below :