mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-11 12:33:45 +03:00
chore: add more logging for browser install process (#23675)
This commit is contained in:
parent
5b2e8a6a7a
commit
9e636687ea
@ -63,12 +63,20 @@ function downloadFile(url: string, destinationPath: string, options: DownloadFil
|
||||
.on('error', handleError);
|
||||
return;
|
||||
}
|
||||
const file = fs.createWriteStream(destinationPath);
|
||||
file.on('finish', () => promise.resolve());
|
||||
file.on('error', error => promise.reject(error));
|
||||
response.pipe(file);
|
||||
totalBytes = parseInt(response.headers['content-length'] || '0', 10);
|
||||
log(`-- total bytes: ${totalBytes}`);
|
||||
const file = fs.createWriteStream(destinationPath);
|
||||
file.on('finish', () => {
|
||||
if (downloadedBytes !== totalBytes) {
|
||||
log(`-- download failed, size mismatch: ${downloadedBytes} != ${totalBytes}`);
|
||||
promise.reject(new Error(`Download failed: size mismatch, file size: ${downloadedBytes}, expected size: ${totalBytes} URL: ${url}`));
|
||||
} else {
|
||||
log(`-- download complete, size: ${downloadedBytes}`);
|
||||
promise.resolve();
|
||||
}
|
||||
});
|
||||
file.on('error', error => promise.reject(error));
|
||||
response.pipe(file);
|
||||
response.on('data', onData);
|
||||
}, (error: any) => promise.reject(error));
|
||||
return promise;
|
||||
|
@ -21,12 +21,12 @@ const CDNS = [
|
||||
'https://playwright-verizon.azureedge.net',
|
||||
];
|
||||
|
||||
const DL_STAT_BLOCK = /^.*from url: (.*)$\n^.*to location: (.*)$\n^.*response status code: (.*)$\n^.*total bytes: (.*)$\n^.*SUCCESS downloading (\w+) .*$/gm;
|
||||
const DL_STAT_BLOCK = /^.*from url: (.*)$\n^.*to location: (.*)$\n^.*response status code: (.*)$\n^.*total bytes: (\d+)$\n^.*download complete, size: (\d+)$\n^.*SUCCESS downloading (\w+) .*$/gm;
|
||||
|
||||
const parsedDownloads = (rawLogs: string) => {
|
||||
const out: { url: string, status: number, name: string }[] = [];
|
||||
for (const match of rawLogs.matchAll(DL_STAT_BLOCK)) {
|
||||
const [, url, /* filepath */, status, /* size */, name] = match;
|
||||
const [, url, /* filepath */, status, /* size */, /* receivedBytes */, name] = match;
|
||||
out.push({ url, status: Number.parseInt(status, 10), name: name.toLocaleLowerCase() });
|
||||
}
|
||||
return out;
|
||||
|
Loading…
Reference in New Issue
Block a user