From 89aa19773c0a1d40699a5a3f9039df734005c5eb Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Sat, 24 Apr 2021 16:55:04 +0200 Subject: [PATCH] fix: extension completely hangs after 6|10 retries of fetching contributors|matching-contexts fixes #861 --- src/app/background/sagas/refreshMatchingContexts.ts | 1 - src/app/sagas/effects/callAndRetry.ts | 5 ++--- src/app/store/sagas/refreshContributors.saga.ts | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app/background/sagas/refreshMatchingContexts.ts b/src/app/background/sagas/refreshMatchingContexts.ts index b6f7748ac..0fbe47a8e 100644 --- a/src/app/background/sagas/refreshMatchingContexts.ts +++ b/src/app/background/sagas/refreshMatchingContexts.ts @@ -15,7 +15,6 @@ import minutesToMilliseconds from 'app/utils/minutesToMilliseconds'; export function* refreshMatchingContextsSaga() { const callAndRetry = createCallAndRetry({ maximumRetryDelayInMinutes: 10, - maximumAttempts: 10, onError: function*(error: Error) { yield put(refreshMatchingContextsFailed(error)); } diff --git a/src/app/sagas/effects/callAndRetry.ts b/src/app/sagas/effects/callAndRetry.ts index 7ff3a8c55..93eef591f 100644 --- a/src/app/sagas/effects/callAndRetry.ts +++ b/src/app/sagas/effects/callAndRetry.ts @@ -8,14 +8,13 @@ import minutesToMilliseconds from 'app/utils/minutesToMilliseconds'; type AnyFunction = (...args: any[]) => any; type OnErrorCallback = (error: Error, failures: number) => void; type Options = { - maximumAttempts: number; + maximumAttempts?: number; maximumRetryDelayInMinutes: number; onError?: OnErrorCallback; onFinalError?: OnErrorCallback; }; const defaultOptions: Options = { - maximumAttempts: 10000, maximumRetryDelayInMinutes: 60 * 24 }; @@ -36,7 +35,7 @@ export const createCallAndRetry = (options: Partial) => if ('onError' in o && o.onError) { yield call(o.onError, e, attemptNumber); } - if (attemptNumber < o.maximumAttempts) { + if (!o.maximumAttempts || attemptNumber < o.maximumAttempts) { yield delay( Math.min( secondsToMilliseconds(2 ^ attemptNumber), diff --git a/src/app/store/sagas/refreshContributors.saga.ts b/src/app/store/sagas/refreshContributors.saga.ts index 340d046ba..e4f4dba50 100644 --- a/src/app/store/sagas/refreshContributors.saga.ts +++ b/src/app/store/sagas/refreshContributors.saga.ts @@ -5,8 +5,7 @@ import fetchContributors from 'api/fetchContributors'; export default function* refreshContributorsSaga() { const callAndRetry = createCallAndRetry({ - maximumRetryDelayInMinutes: 120, - maximumAttempts: 6, + maximumRetryDelayInMinutes: 10, onError: function*(error: Error) { yield put(refreshContributorsFailed(error)); }