Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ import {
writeRepoStates,
} from "./repo-states-store";
import { GITHUB_AUTH_PROVIDER_ID } from "../common/vscode/authentication";
import { FetchError } from "node-fetch";
import { extLogger } from "../common";

const maxRetryCount = 3;

export class VariantAnalysisManager
extends DisposableObject
Expand Down Expand Up @@ -613,12 +617,35 @@ export class VariantAnalysisManager
});
}
};
await this.variantAnalysisResultsManager.download(
variantAnalysis.id,
repoTask,
this.getVariantAnalysisStorageLocation(variantAnalysis.id),
updateRepoStateCallback,
);
let retry = 0;
for (;;) {
try {
await this.variantAnalysisResultsManager.download(
variantAnalysis.id,
repoTask,
this.getVariantAnalysisStorageLocation(variantAnalysis.id),
updateRepoStateCallback,
);
break;
} catch (e) {
if (
retry++ < maxRetryCount &&
e instanceof FetchError &&
(e.code === "ETIMEDOUT" || e.code === "ECONNRESET")
) {
void extLogger.log(
`Timeout while trying to download variant analysis with id: ${
variantAnalysis.id
}. Error: ${getErrorMessage(e)}. Retrying...`,
);
continue;
}
void extLogger.log(
`Failed to download variant analysis after ${retry} attempts.`,
);
throw e;
}
}
} catch (e) {
repoState.downloadStatus =
VariantAnalysisScannedRepositoryDownloadStatus.Failed;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appendFile, pathExists } from "fs-extra";
import { appendFile, pathExists, rm } from "fs-extra";
import fetch from "node-fetch";
import { EOL } from "os";
import { join } from "path";
Expand Down Expand Up @@ -82,6 +82,9 @@ export class VariantAnalysisResultsManager extends DisposableObject {

const zipFilePath = join(resultDirectory, "results.zip");

// in case of restarted download delete possible artifact from previous download
await rm(zipFilePath, { force: true });

const response = await fetch(repoTask.artifactUrl);

let responseSize = parseInt(response.headers.get("content-length") || "0");
Expand Down