@@ -75,6 +75,10 @@ import {
7575 writeRepoStates ,
7676} from "./repo-states-store" ;
7777import { GITHUB_AUTH_PROVIDER_ID } from "../common/vscode/authentication" ;
78+ import { FetchError } from "node-fetch" ;
79+ import { extLogger } from "../common" ;
80+
81+ const maxRetryCount = 3 ;
7882
7983export class VariantAnalysisManager
8084 extends DisposableObject
@@ -613,12 +617,35 @@ export class VariantAnalysisManager
613617 } ) ;
614618 }
615619 } ;
616- await this . variantAnalysisResultsManager . download (
617- variantAnalysis . id ,
618- repoTask ,
619- this . getVariantAnalysisStorageLocation ( variantAnalysis . id ) ,
620- updateRepoStateCallback ,
621- ) ;
620+ let retry = 0 ;
621+ for ( ; ; ) {
622+ try {
623+ await this . variantAnalysisResultsManager . download (
624+ variantAnalysis . id ,
625+ repoTask ,
626+ this . getVariantAnalysisStorageLocation ( variantAnalysis . id ) ,
627+ updateRepoStateCallback ,
628+ ) ;
629+ break ;
630+ } catch ( e ) {
631+ if (
632+ retry ++ < maxRetryCount &&
633+ e instanceof FetchError &&
634+ ( e . code === "ETIMEDOUT" || e . code === "ECONNRESET" )
635+ ) {
636+ void extLogger . log (
637+ `Timeout while trying to download variant analysis with id: ${
638+ variantAnalysis . id
639+ } . Error: ${ getErrorMessage ( e ) } . Retrying...`,
640+ ) ;
641+ continue ;
642+ }
643+ void extLogger . log (
644+ `Failed to download variant analysis after ${ retry } attempts.` ,
645+ ) ;
646+ throw e ;
647+ }
648+ }
622649 } catch ( e ) {
623650 repoState . downloadStatus =
624651 VariantAnalysisScannedRepositoryDownloadStatus . Failed ;
0 commit comments