Home > Blockchain >  Getting an error wrapping Playwright in a Docker image
Getting an error wrapping Playwright in a Docker image

Time:10-12

Getting some errors after I've wrapped my Playwright project in a Docker image. I'm using Firefox in Playwright.

Dockerfile

FROM mcr.microsoft.com/playwright:next

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm ci

COPY . .

RUN npx playwright install

CMD ["node","index.js"]

Package.json dependencies

"@extra/humanize": "^4.2.2-next.616",
"playwright": "^1.15.0",
"playwright-extra": "^4.2.1-next.616"

index.js

const { firefox } = require('playwright');

(async () => {
  const browser = await firefox.launch();
  const page = await browser.newPage();
  await page.goto('http://whatsmyuseragent.org/');
  await page.screenshot({ path: `example.png` });
  await browser.close();
})();

It builds fine, but when I'm running it I'm getting this error:

browserType.launch: Protocol error (Browser.enable): Browser closed.

==================== Browser output: ====================

<launching> /ms-playwright/firefox-1225/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-q4UuZi -juggler-pipe -silent

<launched> pid=965

[err] *** You are running in headless mode.

[err] [Parent 965, Main Thread] WARNING: failed to seal memfd: Invalid argument: file /mnt/actions-runner/_work/playwright-internal/playwright-internal/browser_patches/firefox/checkout/ipc/chromium/src/base/shared_memory_posix.cc:461

[err] [Parent 965, Main Thread] WARNING: freezeable shared memory was never frozen: file /mnt/actions-runner/_work/playwright-internal/playwright-internal/browser_patches/firefox/checkout/ipc/chromium/src/base/shared_memory_posix.cc:543

UPDATE:

If anyone is having the same issue, I found out that the Docker image is not valid on MacBook M1 (which I'm running) sadly :(

CodePudding user response:

As you have already stated, this is a bug (which is now in a feature request), since the docker file given by MS Devs fails for the M1 Macs.

Here is the link to the feature request - https://github.com/microsoft/playwright/issues/7723

  • Related