Apify Discord Mirror

Updated 2 weeks ago

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.

Plain Text
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:
Plain Text
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
`
a
L
s
5 comments
Can you try with headless: "new" ?
I tried it like this:
Plain Text
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:
Plain Text
browserType.launchPersistentContext: headless: expected boolean, got string
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)
@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)
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.
Add a reply
Sign up and join the conversation on Discord