Bump high water mark when downloading bundle to 16 MB

This commit is contained in:
Henry Mercer 2024-10-22 19:58:23 +01:00
parent 8c3a732e36
commit 06361b4d2b
6 changed files with 35 additions and 5 deletions

10
lib/tools-download.js generated
View file

@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.STREAMING_HIGH_WATERMARK_BYTES = void 0;
exports.downloadAndExtract = downloadAndExtract;
const path = __importStar(require("path"));
const perf_hooks_1 = require("perf_hooks");
@ -33,6 +34,10 @@ const feature_flags_1 = require("./feature-flags");
const logging_1 = require("./logging");
const tar = __importStar(require("./tar"));
const util_1 = require("./util");
/**
* High watermark to use when streaming the download and extraction of the CodeQL tools.
*/
exports.STREAMING_HIGH_WATERMARK_BYTES = 4 * 1024 * 1024; // 4 MiB
function makeDownloadFirstToolsDownloadDurations(downloadDurationMs, extractionDurationMs) {
return {
combinedDurationMs: downloadDurationMs + extractionDurationMs,
@ -96,7 +101,10 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
}
async function downloadAndExtractZstdWithStreaming(codeqlURL, authorization, headers, tarVersion, logger) {
headers = Object.assign({ "User-Agent": "CodeQL Action", authorization }, headers);
const response = await new Promise((resolve) => follow_redirects_1.https.get(codeqlURL, { headers }, (r) => resolve(r)));
const response = await new Promise((resolve) => follow_redirects_1.https.get(codeqlURL, {
headers,
highWaterMark: exports.STREAMING_HIGH_WATERMARK_BYTES,
}, (r) => resolve(r)));
if (response.statusCode !== 200) {
throw new Error(`Failed to download CodeQL bundle from ${codeqlURL}. HTTP status code: ${response.statusCode}.`);
}