Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heroku-22 stack support #20

Merged
merged 7 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const { chromium } = require("playwright-chromium");
const browser = await chromium.launch({ chromiumSandbox: false });
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.goto("http://whatsmyuseragent.org/");
await page.screenshot({ path: `chromium.png` });
await browser.close();
})();
Expand All @@ -48,7 +48,7 @@ const { firefox } = require("playwright-firefox");
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.goto("http://whatsmyuseragent.org/");
await page.screenshot({ path: `firefox.png` });
await browser.close();
})();
Expand All @@ -57,3 +57,25 @@ const { firefox } = require("playwright-firefox");
## Best practises

It's common to only install the [browser-specific NPM packages](https://playwright.dev/#version=v1.1.1&path=docs%2Finstallation.md&q=download-single-browser-binary), which will reduce installation time and slug size on Heroku in the end, that should fix also the error that the slug size is too large.

If you encounter this error at runtime, it means that you are missing the chromium binary, which can be installed with `playwright install chromium`.

```
browserType.launch: Executable doesn't exist at /app/node_modules/playwright-core/.local-browsers/chromium-1012/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ npx playwright install ║
║ ║
║ <3 Playwright Team ║
╚═════════════════════════════════════════════════════════════════════════╝
```

You can incorporate this into Heroku's build step by including this script in `package.json`.

```
"scripts": {
"heroku-cleanup": "yarn run playwright install [chromium | webkit | firefox]"
}
```
8 changes: 7 additions & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ install_system_deps() {
if [[ "$SUPPORTED_BROWSERS" == *"chromium"* ]]; then
cat << EOF >>$build_tmpdir/Aptfile
# Chromium dependencies
libnspr4
libnss3
libxss1
libasound2
Expand Down Expand Up @@ -82,10 +83,15 @@ EOF
"heroku-20")
cat << EOF >>$build_tmpdir/Aptfile
libvpx6
EOF
;;
"heroku-22")
cat << EOF >>$build_tmpdir/Aptfile
libvpx7
EOF
;;
*)
error "STACK must be 'heroku-18' or 'heroku-20'"
error "STACK must be 'heroku-18', 'heroku-20', or 'heroku-22'"
esac

local cache_tmpdir=$(mktemp -d)
Expand Down