From d000ddc0b3e32d802d651fdfd454bae4aad6f873 Mon Sep 17 00:00:00 2001 From: secondl1ght Date: Tue, 19 Dec 2023 22:16:53 -0700 Subject: [PATCH] add exponential backoff for axios retries --- src/lib/map/setup.ts | 2 +- src/lib/sync/areas.ts | 2 +- src/lib/sync/elements.ts | 2 +- src/lib/sync/events.ts | 2 +- src/lib/sync/reports.ts | 2 +- src/lib/sync/users.ts | 2 +- src/routes/add-location/endpoint/+server.ts | 2 +- src/routes/boost/invoice/generate/+server.ts | 2 +- src/routes/boost/post/+server.ts | 2 +- src/routes/communities/add/endpoint/+server.ts | 2 +- src/routes/community/[area]/+page.server.ts | 2 +- src/routes/merchant/[id]/+page.svelte | 2 +- src/routes/merchant/[id]/+page.ts | 2 +- src/routes/tagger/[id]/+page.ts | 2 +- src/routes/tickets/endpoint/+server.ts | 2 +- src/routes/verify-location/endpoint/+server.ts | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/map/setup.ts b/src/lib/map/setup.ts index b83e12ac..a6464f38 100644 --- a/src/lib/map/setup.ts +++ b/src/lib/map/setup.ts @@ -8,7 +8,7 @@ import type { DivIcon, Map } from 'leaflet'; import Time from 'svelte-time'; import { get } from 'svelte/store'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); export const toggleMapButtons = () => { const zoomInBtn: HTMLAnchorElement | null = document.querySelector('.leaflet-control-zoom-in'); diff --git a/src/lib/sync/areas.ts b/src/lib/sync/areas.ts index b17b5cd8..eda74aef 100644 --- a/src/lib/sync/areas.ts +++ b/src/lib/sync/areas.ts @@ -4,7 +4,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import localforage from 'localforage'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const limit = 500; diff --git a/src/lib/sync/elements.ts b/src/lib/sync/elements.ts index d10d6d39..b990eaca 100644 --- a/src/lib/sync/elements.ts +++ b/src/lib/sync/elements.ts @@ -5,7 +5,7 @@ import axiosRetry from 'axios-retry'; import localforage from 'localforage'; import { get } from 'svelte/store'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const limit = 5000; diff --git a/src/lib/sync/events.ts b/src/lib/sync/events.ts index c82e4ac5..ad6cd1be 100644 --- a/src/lib/sync/events.ts +++ b/src/lib/sync/events.ts @@ -4,7 +4,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import localforage from 'localforage'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const limit = 50000; diff --git a/src/lib/sync/reports.ts b/src/lib/sync/reports.ts index 3f81f1dd..39fa307b 100644 --- a/src/lib/sync/reports.ts +++ b/src/lib/sync/reports.ts @@ -4,7 +4,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import localforage from 'localforage'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const limit = 20000; diff --git a/src/lib/sync/users.ts b/src/lib/sync/users.ts index 91108648..bd0c2411 100644 --- a/src/lib/sync/users.ts +++ b/src/lib/sync/users.ts @@ -4,7 +4,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import localforage from 'localforage'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const limit = 7500; diff --git a/src/routes/add-location/endpoint/+server.ts b/src/routes/add-location/endpoint/+server.ts index b3233af4..084a727f 100644 --- a/src/routes/add-location/endpoint/+server.ts +++ b/src/routes/add-location/endpoint/+server.ts @@ -9,7 +9,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import crypto from 'crypto'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const used: string[] = []; // @ts-expect-error diff --git a/src/routes/boost/invoice/generate/+server.ts b/src/routes/boost/invoice/generate/+server.ts index 682897f0..3aba8ee0 100644 --- a/src/routes/boost/invoice/generate/+server.ts +++ b/src/routes/boost/invoice/generate/+server.ts @@ -3,7 +3,7 @@ import { error } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); // generate and return invoice // @ts-expect-error diff --git a/src/routes/boost/post/+server.ts b/src/routes/boost/post/+server.ts index fd9b478f..42f52fa7 100644 --- a/src/routes/boost/post/+server.ts +++ b/src/routes/boost/post/+server.ts @@ -3,7 +3,7 @@ import { error, json } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const used: string[] = []; diff --git a/src/routes/communities/add/endpoint/+server.ts b/src/routes/communities/add/endpoint/+server.ts index dfcda07c..e4a5d657 100644 --- a/src/routes/communities/add/endpoint/+server.ts +++ b/src/routes/communities/add/endpoint/+server.ts @@ -4,7 +4,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import crypto from 'crypto'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const used: string[] = []; diff --git a/src/routes/community/[area]/+page.server.ts b/src/routes/community/[area]/+page.server.ts index 2ca57861..69f983fc 100644 --- a/src/routes/community/[area]/+page.server.ts +++ b/src/routes/community/[area]/+page.server.ts @@ -3,7 +3,7 @@ import { error } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); // @ts-expect-error export async function load({ params }) { diff --git a/src/routes/merchant/[id]/+page.svelte b/src/routes/merchant/[id]/+page.svelte index 5ad6cefa..5a02720e 100644 --- a/src/routes/merchant/[id]/+page.svelte +++ b/src/routes/merchant/[id]/+page.svelte @@ -210,7 +210,7 @@ !dataInitialized && initializeData(); - axiosRetry(axios, { retries: 3 }); + axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); let merchant: Element | undefined; diff --git a/src/routes/merchant/[id]/+page.ts b/src/routes/merchant/[id]/+page.ts index 8fafe022..e60bac4b 100644 --- a/src/routes/merchant/[id]/+page.ts +++ b/src/routes/merchant/[id]/+page.ts @@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); // @ts-expect-error export async function load({ params }) { diff --git a/src/routes/tagger/[id]/+page.ts b/src/routes/tagger/[id]/+page.ts index 7b4c740d..cf4f5ee2 100644 --- a/src/routes/tagger/[id]/+page.ts +++ b/src/routes/tagger/[id]/+page.ts @@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); // @ts-expect-error export async function load({ params }) { diff --git a/src/routes/tickets/endpoint/+server.ts b/src/routes/tickets/endpoint/+server.ts index e6ec6e29..874ea73b 100644 --- a/src/routes/tickets/endpoint/+server.ts +++ b/src/routes/tickets/endpoint/+server.ts @@ -3,7 +3,7 @@ import { json } from '@sveltejs/kit'; import axios from 'axios'; import axiosRetry from 'axios-retry'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); export async function GET() { const headers = { diff --git a/src/routes/verify-location/endpoint/+server.ts b/src/routes/verify-location/endpoint/+server.ts index 86f8aac8..7f1f7f08 100644 --- a/src/routes/verify-location/endpoint/+server.ts +++ b/src/routes/verify-location/endpoint/+server.ts @@ -9,7 +9,7 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; import crypto from 'crypto'; -axiosRetry(axios, { retries: 3 }); +axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); const used: string[] = [];