Playwright chrome browser fails on Apify platform
# apify-platform
l
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.
Copy code
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:
Copy code
Dockerfile
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
`
https://cdn.discordapp.com/attachments/1337487080527368212/1337487080883879936/message.txt?ex=67a79f69&is=67a64de9&hm=e4ef15995627e61c76d1500067a54b9c9bba151e22962842b9b6aee2cf04f29b&
h
Someone will reply to you shortly. In the meantime, this might help:
a
Can you try with
headless: "new"
?
l
I tried it like this:
Copy code
javascript
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:
Copy code
browserType.launchPersistentContext: headless: expected boolean, got string
a
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)
s
@louisdck 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)
l
Thanks for confirming @serge_vdw 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.