From 8962f33bcfca1766cdd6afce9359706759cdd39f Mon Sep 17 00:00:00 2001 From: Daniel Caspi Date: Tue, 7 Nov 2023 20:46:30 -0600 Subject: [PATCH] fix retry logic "Unable to find Bond for IP Address" #229 --- src/BondApi.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/BondApi.ts b/src/BondApi.ts index b3b2136..c0df4f4 100644 --- a/src/BondApi.ts +++ b/src/BondApi.ts @@ -31,7 +31,23 @@ export class BondApi { this.bondToken = bondToken; this.uri = new BondUri(ipAddress); - axiosRetry(axios, { retries: 10, retryDelay: axiosRetry.exponentialDelay }); + axiosRetry(axios, { + retries: 10, + retryDelay: axiosRetry.exponentialDelay, + shouldResetTimeout: true, + retryCondition: (error) => { + const shouldRetry = axiosRetry.isNetworkOrIdempotentRequestError(error) || error.code === 'ECONNABORTED'; + + this.platform.log.debug(`Retrying: ${shouldRetry ? 'YES' : 'NO'}`, { + url: error.config?.url, + method: error.config?.method, + errorCode: error.code, + responseStatus: error.response?.status + }); + + return shouldRetry; + } + }); } // Bond / Device Info