import * as retry from 'p-retry' ; import { IActionContext , parseError } from 'vscode-azureextensionui' ; /**
 * Kudu calls are not the most reliable - this will retry a few times with exponential backoff. Each "set" of retries will take a max of about 15 seconds
 */ export async function retryKuduCall < T > ( context , methodName , callback ) { return await retry ( async ( attempt ) => { if ( attempt > 1 ) { const existingAttempt = context . telemetry . measurements . kuduMaxRetry ; if ( existingAttempt === undefined || existingAttempt < attempt ) { context . telemetry . measurements . kuduMaxRetry = attempt ; context . telemetry . properties . kuduRetryMethod = methodName ; } } return await callback ( ) ; } , { retries : 4 , minTimeout : 1000 } ) ; } /**
 * 404 is somewhat common when listing deployment logs. This will swallow the error and display the logs we _can_ retrieve
 * https://github.com/microsoft/vscode-azureappservice/issues/1365
 */ export async function ignore404Error ( context , callback ) { try { await callback ( ) ; } catch ( error ) { if ( parseError ( error ) . errorType === '404' ) { context . telemetry . properties . ignore404Error = 'true' ; } else { throw error ; } } }