diff --git a/.circleci/config.yml b/.circleci/config.yml index eb6e8f8..51ee3a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,7 +82,7 @@ jobs: name: ESLint command: | yarn install - npm run eslint + npm run lint test: <<: *defaults diff --git a/src/datasource/alert_helper.ts b/src/datasource/alert_helper.ts index 99701a2..251425b 100644 --- a/src/datasource/alert_helper.ts +++ b/src/datasource/alert_helper.ts @@ -14,7 +14,7 @@ function showAlert(error: any) { message += error; } - appEvents.emit('alert-error', ["Can't connect to Kentik API", message]); + appEvents.emit('alert-error', ["Kentik API Error", message]); } function showCustomAlert(message: string, exceptionData: any, exceptionType: any) { diff --git a/src/datasource/kentik_api.ts b/src/datasource/kentik_api.ts index 8af337c..d3a5c8b 100644 --- a/src/datasource/kentik_api.ts +++ b/src/datasource/kentik_api.ts @@ -153,9 +153,8 @@ export class KentikAPI { } } -const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, retriesLeft = 100, interval = 1000) => +const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, retriesLeft = 5, interval = 2000) => new Promise((resolve, reject) => { - console.log(`Retries left: ${retriesLeft} - Next retry interval: ${interval}`); fn() .then(resolve) .catch((error: FetchError) => { @@ -164,13 +163,13 @@ const retry = (fn: Function, shouldContinue: (error: FetchError) => boolean, ret return; } if (retriesLeft === 0) { - // Maximum retries exceeded + showAlert('Maximum number of retries exceeded, please reload the page'); reject(error); return; } setTimeout(() => { // Passing on "reject" is the important part - retry(fn, shouldContinue, retriesLeft - 1, interval + 1000).then(resolve, reject); + retry(fn, shouldContinue, retriesLeft - 1, interval * 2).then(resolve, reject); }, interval); }); });