Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: improve error reporting when browse download fails (#4787)

Yury Semikhatsky7bbda4370d45
diff --git a/install-from-github.js b/install-from-github.js
index 5cf94cece1..ac44f4823c 100644
--- a/install-from-github.js
+++ b/install-from-github.js
@@ -27,6 +27,9 @@ try {
console.log(`Downloading browsers...`);
const { installBrowsersWithProgressBar } = require('./lib/install/installer');
-installBrowsersWithProgressBar(__dirname);
+installBrowsersWithProgressBar(__dirname).catch(e => {
+ console.error(`Failed to install browsers, caused by\n${e.stack}`);
+ process.exit(1);
+});
console.log(`Done. Use "npm run watch" to compile.`);
diff --git a/src/install/installer.ts b/src/install/installer.ts
index c8a2c97c26..6c12eb65e8 100644
--- a/src/install/installer.ts
+++ b/src/install/installer.ts
@@ -103,7 +103,9 @@ async function validateCache(packagePath: string, browsersPath: string, linksDir
// 3. Install missing browsers for this package.
const myBrowsersToDownload = await readBrowsersToDownload(packagePath);
for (const browser of myBrowsersToDownload) {
- await browserFetcher.downloadBrowserWithProgressBar(browsersPath, browser);
+ await browserFetcher.downloadBrowserWithProgressBar(browsersPath, browser).catch(e => {
+ throw new Error(`Failed to download ${browser.name}, caused by\n${e.stack}`);
+ });
await fsWriteFileAsync(browserPaths.markerFilePath(browsersPath, browser), '');
}
}