playwright: [BUG] Chromium fails to download

System info

  • Playwright Version: 1.41.0-alpha-nov-24-2023
  • Operating System: macOS 14.0
  • Browser: Chromium
  • Other info:

Steps

  • npm install playwright@next
  • npx playwright install

Expected

Browsers get installed.

Actual

% npx playwright install        
Removing unused browser at /Users/martin/Library/Caches/ms-playwright/chromium-1041
Downloading Chromium 120.0.6099.35 (playwright build v1092) from https://playwright.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
131 MiB [=================== ] 96% 2.4sError: Download failed: server closed connection. URL: https://playwright.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
    at IncomingMessage.<anonymous> (/Users/martin/Documents/GitHub/frontends/node_modules/playwright/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js:89:22)
    at IncomingMessage.emit (node:events:517:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
Downloading Chromium 120.0.6099.35 (playwright build v1092) from https://playwright-akamai.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
131 MiB [=================== ] 95% 2.3sError: Download failed: server closed connection. URL: https://playwright-akamai.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
    at IncomingMessage.<anonymous> (/Users/martin/Documents/GitHub/frontends/node_modules/playwright/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js:89:22)
    at IncomingMessage.emit (node:events:517:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
Downloading Chromium 120.0.6099.35 (playwright build v1092) from https://playwright-verizon.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
131 MiB [====================] 97% 1.2sError: Download failed: server closed connection. URL: https://playwright-verizon.azureedge.net/builds/chromium/1092/chromium-mac-arm64.zip
    at IncomingMessage.<anonymous> (/Users/martin/Documents/GitHub/frontends/node_modules/playwright/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js:89:22)
    at IncomingMessage.emit (node:events:517:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
Failed to install browsers
Error: Failed to download Chromium 120.0.6099.35 (playwright build v1092), caused by
Error: Download failure, code=1
    at ChildProcess.<anonymous> (/Users/martin/Documents/GitHub/frontends/node_modules/playwright/node_modules/playwright-core/lib/server/registry/browserFetcher.js:91:16)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

This looks related to https://github.com/microsoft/playwright/issues/28189.

I can successfully download and unzip https://playwright.azureedge.net/builds/chromium/1091/chromium-mac-arm64.zip from Firefox, but it reliably fails to download from npx playwright install

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 1
  • Comments: 19 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve just retested using "@playwright/test": "^1.40.0",:

I’m based in Bristol, UK. My home internet is a 5G connection provided by https://www.three.co.uk/. Running over this connection:

% npx playwright install                                              
Removing unused browser at /Users/martin/Library/Caches/ms-playwright/chromium-1091
Downloading Chromium 120.0.6099.28 (playwright build v1091) from https://playwright.azureedge.net/builds/chromium/1091/chromium-mac-arm64.zip
131 Mb [====================] 98% 0.6s <hangs at this point>

Switching to tethering through my mobile which has internet provided by https://ee.co.uk/:

% npx playwright install
Downloading Chromium 120.0.6099.28 (playwright build v1091) from https://playwright.azureedge.net/builds/chromium/1091/chromium-mac-arm64.zip
131 Mb [====================] 100% 0.0s
Chromium 120.0.6099.28 (playwright build v1091) downloaded to /Users/martin/Library/Caches/ms-playwright/chromium-1091
Downloading Firefox 119.0 (playwright build v1429) from https://playwright.azureedge.net/builds/firefox/1429/firefox-mac-13-arm64.zip
73.6 Mb [====================] 100% 0.0s
Firefox 119.0 (playwright build v1429) downloaded to /Users/martin/Library/Caches/ms-playwright/firefox-1429
Downloading Webkit 17.4 (playwright build v1944) from https://playwright.azureedge.net/builds/webkit/1944/webkit-mac-13-arm64.zip
62.3 Mb [====================] 100% 0.0s
Webkit 17.4 (playwright build v1944) downloaded to /Users/martin/Library/Caches/ms-playwright/webkit-1944

So I can confirm that this appears to be an ISP specific issue.

That’s odd. When I was on Three 5G wifi, connecting to a VPN (e.g. CloudFlare Wrap) allowed me to download binaries via npx playwright install / pnpm exec playwright install.

I also have Three 5G internet and see the same issue. The workaround of downloading it manually fixes it for me too (not sure why it should be different from what it’s doing automatically though?)

To make it a bit easier, I wrote a script:

#!/bin/sh
set -e

INFO="$(yarn playwright install chromium --with-deps --dry-run)"
LOCN="$(echo "$INFO" | grep 'Install location' | sed 's/^[^:]*: *//')"
SRC="$(echo "$INFO" | grep 'Download url' | sed 's/^[^:]*: *//')"

echo "Downloading from $SRC to $LOCN"

mkdir -p "$LOCN"

rm "$LOCN/temp-chrome.zip" 2>/dev/null || true
curl "$SRC" > "$LOCN/temp-chrome.zip"
unzip "$LOCN/temp-chrome.zip" -d "$LOCN"
rm "$LOCN/temp-chrome.zip"

(replace yarn with npx if using NPM as your package manager)

Closing as per above then and the enhancement in https://github.com/microsoft/playwright/pull/28344 has landed.

To summarise: <= 1.40 we were hanging. On main we don’t hang anymore. We fail instead on all CDNs. This does not fix the issue but makes it clearer to the user that the file can’t be downloaded.

In https://github.com/microsoft/playwright/pull/28344 we’ll improve the way we throw instead of hanging.

““Chromium” is damaged and can’t be opened. You should move it to the Bin.” turns out to be a known issue and I’ve fixed it by using brew install chromium followed by running xattr -rc /Applications/Chromium.app as per https://chromium.googlesource.com/chromium/src.git/+/main/docs/mac_arm64.md. I was then able to copy the Chromium binary into place: cp -r /Applications/Chromium.app /Users/martin/Library/Caches/ms-playwright/chromium-1091/chrome-mac/.

This has unblocked me for now, but I still can’t get playwright to handle downloading Chromium.