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);
|
.on('error', handleError);
|
||||||
return;
|
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);
|
totalBytes = parseInt(response.headers['content-length'] || '0', 10);
|
||||||
log(`-- total bytes: ${totalBytes}`);
|
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);
|
response.on('data', onData);
|
||||||
}, (error: any) => promise.reject(error));
|
}, (error: any) => promise.reject(error));
|
||||||
return promise;
|
return promise;
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ const CDNS = [
|
||||||
'https://playwright-verizon.azureedge.net',
|
'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 parsedDownloads = (rawLogs: string) => {
|
||||||
const out: { url: string, status: number, name: string }[] = [];
|
const out: { url: string, status: number, name: string }[] = [];
|
||||||
for (const match of rawLogs.matchAll(DL_STAT_BLOCK)) {
|
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() });
|
out.push({ url, status: Number.parseInt(status, 10), name: name.toLocaleLowerCase() });
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue