From c37377bbc4330742187930e3ba733784309ebe14 Mon Sep 17 00:00:00 2001 From: Chris Copsey <150505+ccopsey@users.noreply.github.com> Date: Mon, 11 Sep 2023 09:32:37 +0100 Subject: [PATCH 1/2] Adds allowRetries and maxRetries to azure-got-wrapper --- lib/modules/platform/azure/azure-got-wrapper.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/modules/platform/azure/azure-got-wrapper.ts b/lib/modules/platform/azure/azure-got-wrapper.ts index d9628cba856dae..5cafe2eb27ebb8 100644 --- a/lib/modules/platform/azure/azure-got-wrapper.ts +++ b/lib/modules/platform/azure/azure-got-wrapper.ts @@ -4,6 +4,7 @@ import type { ICoreApi } from 'azure-devops-node-api/CoreApi'; import type { IGitApi } from 'azure-devops-node-api/GitApi'; import type { IPolicyApi } from 'azure-devops-node-api/PolicyApi'; import type { IRequestHandler } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; +import type { IRequestOptions } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; import type { HostRule } from '../../../types'; import * as hostRules from '../../../util/host-rules'; @@ -18,13 +19,21 @@ function getAuthenticationHandler(config: HostRule): IRequestHandler { return getHandlerFromToken(config.token!, true); } +function getRequestOptions() : IRequestOptions { + let options: IRequestOptions = {}; + options.allowRetries = true; + options.maxRetries = 2; + return options; +} + export function azureObj(): azure.WebApi { const config = hostRules.find({ hostType, url: endpoint }); if (!config.token && !(config.username && config.password)) { throw new Error(`No config found for azure`); } const authHandler = getAuthenticationHandler(config); - return new azure.WebApi(endpoint, authHandler); + const requestOptions = getRequestOptions(); + return new azure.WebApi(endpoint, authHandler, requestOptions); } export function gitApi(): Promise { From 1392655e9cfc65de5fe41f3d00bb9c167c60b67a Mon Sep 17 00:00:00 2001 From: Chris Copsey <150505+ccopsey@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:45:32 +0100 Subject: [PATCH 2/2] Inlined for simplicity --- lib/modules/platform/azure/azure-got-wrapper.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/modules/platform/azure/azure-got-wrapper.ts b/lib/modules/platform/azure/azure-got-wrapper.ts index 5cafe2eb27ebb8..4dbfc72dfe5e41 100644 --- a/lib/modules/platform/azure/azure-got-wrapper.ts +++ b/lib/modules/platform/azure/azure-got-wrapper.ts @@ -4,7 +4,6 @@ import type { ICoreApi } from 'azure-devops-node-api/CoreApi'; import type { IGitApi } from 'azure-devops-node-api/GitApi'; import type { IPolicyApi } from 'azure-devops-node-api/PolicyApi'; import type { IRequestHandler } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; -import type { IRequestOptions } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; import type { HostRule } from '../../../types'; import * as hostRules from '../../../util/host-rules'; @@ -19,21 +18,16 @@ function getAuthenticationHandler(config: HostRule): IRequestHandler { return getHandlerFromToken(config.token!, true); } -function getRequestOptions() : IRequestOptions { - let options: IRequestOptions = {}; - options.allowRetries = true; - options.maxRetries = 2; - return options; -} - export function azureObj(): azure.WebApi { const config = hostRules.find({ hostType, url: endpoint }); if (!config.token && !(config.username && config.password)) { throw new Error(`No config found for azure`); } const authHandler = getAuthenticationHandler(config); - const requestOptions = getRequestOptions(); - return new azure.WebApi(endpoint, authHandler, requestOptions); + return new azure.WebApi(endpoint, authHandler, { + allowRetries: true, + maxRetries: 2, + }); } export function gitApi(): Promise {