in lib/Utils/FetchUtils.js [50:102]
function httpClientRetries(urlSuffix_1, header_1, method_1) {
return __awaiter(this, arguments, void 0, function* (urlSuffix, header, method, retries = 1, data, isUploadCall = true, log = true) {
let httpResponse;
try {
let correlationId = `gh-actions-${(0, CommonUtils_1.getUniqueId)()}`;
header[UtilModels_1.correlationHeader] = correlationId; // even if we put console.debug its printing along with the logs, so lets just go ahead with the differentiation with azdo, so we can search the timeframe for azdo in correlationid and resource filter.
if (method == UtilModels_1.FetchCallType.get) {
httpResponse = yield httpClient.get(urlSuffix, header);
}
else if (method == UtilModels_1.FetchCallType.delete) {
httpResponse = yield httpClient.del(urlSuffix, header);
}
else if (method == UtilModels_1.FetchCallType.post) {
httpResponse = yield httpClient.post(urlSuffix, data, header);
}
else if (method == UtilModels_1.FetchCallType.put && isUploadCall) {
let fileContent = (0, FileUtils_1.uploadFileData)(data);
httpResponse = yield httpClient.request(methodEnumToString[method], urlSuffix, fileContent, header);
}
else {
const githubBaseUrl = process.env.GITHUB_SERVER_URL;
const repository = process.env.GITHUB_REPOSITORY;
const runId = process.env.GITHUB_RUN_ID;
const pipelineName = process.env.GITHUB_WORKFLOW || "Unknown Pipeline";
const pipelineUri = `${githubBaseUrl}/${repository}/actions/runs/${runId}`;
header['x-ms-pipeline-name'] = pipelineName; // setting these for patch calls.
header['x-ms-pipeline-uri'] = pipelineUri;
httpResponse = yield httpClient.request(methodEnumToString[method], urlSuffix, data, header);
}
if (httpResponse.message.statusCode != undefined && httpResponse.message.statusCode >= 300) {
CoreUtils.debug(`correlation id : ${correlationId}`);
}
if (httpResponse.message.statusCode != undefined && [408, 429, 502, 503, 504].includes(httpResponse.message.statusCode)) {
let err = yield (0, CommonUtils_1.getResultObj)(httpResponse);
throw { message: (err && err.error && err.error.message) ? err.error.message : (0, CommonUtils_1.errorCorrection)(httpResponse) }; // throwing as message to catch it as err.message
}
return httpResponse;
}
catch (err) {
if (retries) {
let sleeptime = (5 - retries) * 1000 + Math.floor(Math.random() * 5001);
if (log) {
console.log(`Failed to connect to ${urlSuffix} due to ${err.message}, retrying in ${sleeptime / 1000} seconds`);
}
yield (0, CommonUtils_1.sleep)(sleeptime);
return yield httpClientRetries(urlSuffix, header, method, retries - 1, data);
}
else {
throw new Error(`Operation did not succeed after 3 retries. Pipeline failed with error : ${err.message}`);
}
}
});
}