Skip to content

Commit

Permalink
fix: upgrade puppeteer to v21 now using "Chrome for Testing"
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Puppeteer now uses "Chrome for Testing" instead of Chromium. This should make the installation of puppeteer's browser more stable especially on Mac computers with Apple silicon (M1/M2/M3).

We now use the new headless mode of Chrome.

A new README section related to Puppeteer is now available: https://github.com/amtrack/sfdx-browserforce-plugin/blob/master/README.md#puppeteer
  • Loading branch information
renovate[bot] authored and amtrack committed Nov 15, 2023
1 parent b575515 commit 26006aa
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 104 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Further benefits:

- comfortable configuration using JSON Schema (similar to the [Scratch Org Definition Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm))
- idempotency of the `apply` command only applies what's necessary and allows re-execution (concept similar to [terraform](https://www.terraform.io/docs/commands/apply.html))
- browser automation powered by [Puppeteer](https://github.com/GoogleChrome/puppeteer) (Chromium)
- browser automation powered by Puppeteer and "Chrome for Testing", [learn more about Puppeteer and Browserforce](#puppeteer)
- implement your own custom preferences (a.k.a. plugins; to be improved)

# Installation
Expand Down Expand Up @@ -162,6 +162,31 @@ Here is a full blown example showing most of the supported settings in action:
- `BROWSERFORCE_RETRY_MAX_RETRIES`: number of retries on failures opening a page (default: `4`)
- `BROWSERFORCE_RETRY_TIMEOUT_MS`: initial time between retries in exponential mode (default: `4000`)

# Puppeteer

We use [Puppeteer](https://github.com/puppeteer/puppeteer) for browser automation which comes with its own "Chrome for Testing" browser.

The puppeteer [installation doc](https://github.com/puppeteer/puppeteer#installation) describes how this works:

> When you install Puppeteer, it automatically downloads a recent version of
> [Chrome for Testing](https://goo.gle/chrome-for-testing) (~170MB macOS, ~282MB Linux, ~280MB Windows) that is [guaranteed to
> work](https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy)
> with Puppeteer. The browser is downloaded to the `$HOME/.cache/puppeteer` folder
> by default (starting with Puppeteer v19.0.0).
In most of the cases this just works! If you still want to skip the download and use another browser installation, you can do this as follows:

```console
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
sf plugins install sfdx-browserforce-plugin
export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
sf browserforce:apply ...
```

Troubleshooting:

- The installation is triggered via the `postinstall` hook of npm/yarn. If you've disabled running scripts with npm (`--ignore-scripts` or via config file), it will not download the browser.

# Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for getting started.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@mdapi-issues/listmetadata-standardvalueset": "2.0.3",
"@salesforce/sf-plugins-core": "4.1.1",
"p-retry": "4.6.2",
"puppeteer": "19.2.0"
"puppeteer": "21.5.1"
},
"devDependencies": {
"@salesforce/dev-config": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/browserforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Browserforce {
// workaround for navigating frames https://github.com/puppeteer/puppeteer/issues/5123
'--disable-features=site-per-process'
],
headless: !(process.env.BROWSER_DEBUG === 'true')
headless: process.env.BROWSER_DEBUG === 'true' ? false : 'new'
});
await this.openPage(
`secur/frontdoor.jsp?sid=${this.org.getConnection().accessToken}&retURL=${encodeURIComponent(POST_LOGIN_PATH)}`
Expand Down
Loading

0 comments on commit 26006aa

Please sign in to comment.