Add retry mechanisms for network operations to fix Connect Timeout Error

Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-14 08:56:51 +00:00
co-authored by eifinger
parent 03f689c6c5
commit 0e7e01552a
6 changed files with 865 additions and 107 deletions
@@ -1,5 +1,11 @@
import { promises as fs } from "node:fs";
import * as tc from "@actions/tool-cache";
import {
isRetryableError,
NonRetryableError,
RetryableError,
withRetry,
} from "../../utils/retry";
import { KNOWN_CHECKSUMS } from "./known-checksums";
export async function updateChecksums(
filePath: string,
@@ -60,6 +66,27 @@ async function getOrDownloadChecksum(
}
async function downloadAssetContent(downloadUrl: string): Promise<string> {
const downloadPath = await tc.downloadTool(downloadUrl);
return await fs.readFile(downloadPath, "utf8");
return await withRetry(
async () => {
try {
const downloadPath = await tc.downloadTool(downloadUrl);
return await fs.readFile(downloadPath, "utf8");
} catch (error) {
const err = error as Error;
if (isRetryableError(err)) {
throw new RetryableError(
`Failed to download checksum file: ${err.message}`,
err,
);
} else {
throw new NonRetryableError(
`Failed to download checksum file: ${err.message}`,
err,
);
}
}
},
{ maxRetries: 3, timeoutMs: 30000 },
"download checksum file",
);
}