mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(launcher): output correct error message for browser (#6815)
* fix(launcher): output correct error message for browser When running `npm run release` today I got this error logged: ``` Error: Could not find browser revision 848005. Run "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary. at ChromeLauncher.launch (/Users/jacktfranklin/src/puppeteer/lib/cjs/puppeteer/node/Launcher.js:80:27) ``` The error is only partially correct; I did have the browser revision missing, but I needed the Chromium browser, not Firefox. It turns out the logic in `Launcher.ts` didn't take this into account; it mistakenly had been hardcoded to always log out the error as if the Firefox binary was missing. This PR updates the message depending on the browser: Chrome error: > Error: Could not find expected browser (chrome) locally. Run npm > install or yarn install to download the correct Chromium revision > (848005). Firefox error: > Error: Could not find expected browser (firefox) locally. Run > "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox > yarn install" to download a supported Firefox browser binary. * Update src/node/Launcher.ts Co-authored-by: Mathias Bynens <mathias@qiwi.be> Co-authored-by: Mathias Bynens <mathias@qiwi.be>
This commit is contained in:
parent
c936b18651
commit
6c61874797
@ -615,6 +615,7 @@ function resolveExecutablePath(
|
||||
product: launcher.product,
|
||||
path: downloadPath,
|
||||
});
|
||||
|
||||
if (!launcher._isPuppeteerCore && launcher.product === 'chrome') {
|
||||
const revision = process.env['PUPPETEER_CHROMIUM_REVISION'];
|
||||
if (revision) {
|
||||
@ -627,8 +628,13 @@ function resolveExecutablePath(
|
||||
}
|
||||
}
|
||||
const revisionInfo = browserFetcher.revisionInfo(launcher._preferredRevision);
|
||||
|
||||
const firefoxHelp = `Run \`PUPPETEER_PRODUCT=firefox npm install\` to download a supported Firefox browser binary.`;
|
||||
const chromeHelp = `Run \`npm install\` to download the correct Chromium revision (${launcher._preferredRevision}).`;
|
||||
const missingText = !revisionInfo.local
|
||||
? `Could not find browser revision ${launcher._preferredRevision}. Run "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.`
|
||||
? `Could not find expected browser (${launcher.product}) locally. ${
|
||||
launcher.product === 'chrome' ? chromeHelp : firefoxHelp
|
||||
}`
|
||||
: null;
|
||||
return { executablePath: revisionInfo.executablePath, missingText };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user