Skip to content

Commit

Permalink
Merge pull request #880 from browserstack/build_artifacts_logging
Browse files Browse the repository at this point in the history
Add usage logging for build artifacts failures
  • Loading branch information
pranavj1001 authored Oct 10, 2024
2 parents a2cbd75 + bfdfd52 commit 29b8388
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/helpers/buildArtifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const parseAndDownloadArtifacts = async (buildId, data, bsConfig, args, rawArgs,
utils.sendUsageReport(bsConfig, args, warningMessage, Constants.messageTypes.ERROR, 'build_artifacts_not_found', buildReportData, rawArgs);
} else {
BUILD_ARTIFACTS_FAIL_COUNT += 1;
const errorMsg = `Error downloading build artifacts for ${sessionId} with error: ${error}`;
logger.debug(errorMsg);
utils.sendUsageReport(bsConfig, args, errorMsg, Constants.messageTypes.ERROR, 'build_artifacts_parse_error', buildReportData, rawArgs);
}
// delete malformed zip if present
let tmpFilePath = path.join(filePath, fileName);
Expand Down Expand Up @@ -102,14 +105,16 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
let tmpFilePath = path.join(filePath, fileName);
const writer = fs.createWriteStream(tmpFilePath);

logger.debug(`Downloading build artifact for: ${filePath}`)
return new Promise(async (resolve, reject) => {
request.get(url).on('response', function(response) {

if(response.statusCode != 200) {
if (response.statusCode === 404) {
reject(Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND);
}
reject();
const errorMsg = `Non 200 status code, got status code: ${response.statusCode}`;
reject(errorMsg);
} else {
//ensure that the user can call `then()` only when the file has
//been downloaded entirely.
Expand Down

0 comments on commit 29b8388

Please sign in to comment.