chrome-debugging-client icon indicating copy to clipboard operation
chrome-debugging-client copied to clipboard

Proposal: Add `spawnOrInstallChrome` method

Open rwjblue opened this issue 5 years ago • 1 comments

Motivation

In scenarios where Chrome would not necessarily be guaranteed to be installed (e.g. CI environments, "end user machines" via npx some-thing) and in those cases using spawnChrome will error (lazily when you actually try to "do something" the first time).

puppeteer "solves" this by always installing Chrome during puppeteers postinstall hook, which takes a bit of time during installation. This ensures that all users have Chrome installed and therefore that puppeteer itself works, but since most of the time the user will already have Chrome installed this leads to wasted work / time.

Proposal

Add a new method (straw man name): spawnOrInstallChrome that will attempt to use the ambiently available Chrome instance (I'm assuming it can literally use spawnChrome for this part), and if an ambient Chrome is not available fall back to fetching Chrome before continuing.

This would reduce wasted time (vs puppeteer's setup and vs setting up Chrome eagerly in CI environments that already have it), but still allow tools that run on "uncontrolled environments" work without putting this problem on the authors of those tools.

Additional Information

See here for how puppeteer fetches and installs Chrome

Example project that needs to be able to run on arbitrary machines (when we cannot know ahead of time that Chrome is installed)

rwjblue avatar Aug 27 '19 18:08 rwjblue

Thank you for the proposal @rwjblue - I am in agreement that this API should be included and will queue the work for this implementation.

lynchbomb avatar Aug 27 '19 19:08 lynchbomb