diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index a7b50d6f6..0886baa1b 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -437,3 +437,8 @@ export class TerminalQueryParams { public static readonly SubscriptionId = "subscriptionId"; public static readonly TerminalEndpoint = "terminalEndpoint"; } + +export class LoadOfferRetry { + public static readonly MaxRetries = 5; + public static readonly RetryAfterMilliSeconds = 5000; +} diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index ea27df1f3..48dad4425 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -162,6 +162,7 @@ export interface Collection extends CollectionBase { loadStoredProcedures(): Promise; loadTriggers(): Promise; loadOffer(): Promise; + loadAutopilotOfferWithRetry(): Promise; createStoredProcedureNode(data: StoredProcedureDefinition & Resource): StoredProcedure; createUserDefinedFunctionNode(data: UserDefinedFunctionDefinition & Resource): UserDefinedFunction; diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index b6b1ba90a..f30d308b0 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -532,11 +532,12 @@ export class SettingsComponent extends React.Component { + let retryCount = 0; + while (retryCount < Constants.LoadOfferRetry.MaxRetries) { + if (this.offer().content.offerAutopilotSettings) { + return this.offer(); + } else { + await new Promise(resolve => setTimeout(resolve, Constants.LoadOfferRetry.RetryAfterMilliSeconds)); + await this.loadOffer(); + } + retryCount++; + } + throw new Error( + "Max Retries for loading offer are completed. Offer does not have an offerAutopilotSettings field." + ); + } + public async loadOffer(): Promise { if (!this.container.isServerlessEnabled() && !this.offer()) { this.container.isRefreshingExplorer(true);