Skip to content

Commit

Permalink
fix: extension completely hangs after 6|10 retries of fetching contri…
Browse files Browse the repository at this point in the history
…butors|matching-contexts

fixes #861
  • Loading branch information
JalilArfaoui committed Apr 24, 2021
1 parent 6ca536f commit 89aa197
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/app/background/sagas/refreshMatchingContexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/sagas/effects/callAndRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand All @@ -36,7 +35,7 @@ export const createCallAndRetry = (options: Partial<Options>) =>
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),
Expand Down
3 changes: 1 addition & 2 deletions src/app/store/sagas/refreshContributors.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 89aa197

Please sign in to comment.