Playwright chrome browser fails on Apify platform

I have a scraper using Playwright, which still works perfectly locally. It also used to work on Apify, but since today it no longer does. Has anything been changed about how Playwright is ran on Apify? The error talks about the old Chrome headles mode being removed? See attachment for the full logs.
2025-02-07T18:07:53.704Z browserType.launchPersistentContext: Target page, context or browser has been closed
2025-02-07T18:07:53.705Z Browser logs: <launching> /home/myuser/pw-browsers/chrome --disable-field-trial-config ...
2025-02-07T18:07:53.708Z <launched> pid=36
2025-02-07T18:07:53.709Z [pid=36][err] Old Headless mode has been removed from the Chrome binary.
2025-02-07T18:07:53.704Z browserType.launchPersistentContext: Target page, context or browser has been closed
2025-02-07T18:07:53.705Z Browser logs: <launching> /home/myuser/pw-browsers/chrome --disable-field-trial-config ...
2025-02-07T18:07:53.708Z <launched> pid=36
2025-02-07T18:07:53.709Z [pid=36][err] Old Headless mode has been removed from the Chrome binary.
Haven't changed anything about the default Dockerfile, here it is:
FROM apify/actor-node-playwright-chrome:20 AS builder
RUN npm ls crawlee apify puppeteer playwright
COPY --chown=myuser package*.json ./
RUN npm install --include=dev --audit=false
COPY --chown=myuser . ./
RUN npm run build
FROM apify/actor-node-playwright-chrome:20
RUN npm ls crawlee apify puppeteer playwright
COPY --chown=myuser package*.json ./
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
COPY --chown=myuser . ./
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent
FROM apify/actor-node-playwright-chrome:20 AS builder
RUN npm ls crawlee apify puppeteer playwright
COPY --chown=myuser package*.json ./
RUN npm install --include=dev --audit=false
COPY --chown=myuser . ./
RUN npm run build
FROM apify/actor-node-playwright-chrome:20
RUN npm ls crawlee apify puppeteer playwright
COPY --chown=myuser package*.json ./
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
COPY --chown=myuser . ./
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent
`
6 Replies
Hall
Hall4mo ago
Someone will reply to you shortly. In the meantime, this might help:
azzouzana
azzouzana4mo ago
Can you try with headless: "new" ?
Louis Deconinck
Louis DeconinckOP4mo ago
I tried it like this:
const crawler = new PlaywrightCrawler({
proxyConfiguration: profileProxyConfiguration,
headless: 'new',
requestHandler: async ({ page, request }) => {
const crawler = new PlaywrightCrawler({
proxyConfiguration: profileProxyConfiguration,
headless: 'new',
requestHandler: async ({ page, request }) => {
But the headless field is a boolean, not a string, so I get this error:
browserType.launchPersistentContext: headless: expected boolean, got string
browserType.launchPersistentContext: headless: expected boolean, got string
azzouzana
azzouzana4mo ago
hmm, interesting. Probably the docker image being pulled on Apify platform is not cached, it installed a chrome version (It installs the latest stable version https://github.com/apify/apify-actor-docker/blob/bd822706bd31148c5dc8d9eebc6998cb2c47ac02/node-playwright-chrome/Dockerfile#L10) without the headless mode which Google said that they'd be splitting the headless mode (where locally it's most likely cached). Are you using a fixed playwright version in package.json or is it *? (I believe you shouldn't use * as it would install a version that might be incompatible with your setup)
correct-apricot
correct-apricot3mo ago
@Louis Deconinck ran into the same problem and fixed it by pinning the playwright version to 1.49.1 in package.json (instead of * which currently installs 1.50.1)
Louis Deconinck
Louis DeconinckOP3mo ago
Thanks for confirming @serge This is probably something Apify should take a look at. I no longer have the problem as I was able to improve my scraper which no longer requires Playwright, but others might run into this as well.

Did you find this page helpful?