Skip to content

Commit

Permalink
feat: remove auto retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Oct 30, 2024
1 parent 3557146 commit 3499abc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/frontend/src/service-worker/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ self.addEventListener("sync", async (event: any) => {
event.waitUntil(syncMissingPictures());
});

const syncMissingPictures = async (retries = 3) => {
const syncMissingPictures = async () => {
try {
const token = await getTokenFromIdb();
if (!token) return void console.log("no token");
Expand All @@ -42,11 +42,7 @@ const syncMissingPictures = async (retries = 3) => {

await syncPicturesById(pictureIds as string[], token);
} catch (e) {
if (retries > 0) {
console.log("retrying in 5s", e);
await new Promise((resolve) => setTimeout(resolve, 5000));
return syncMissingPictures(retries - 1);
}
console.error("sync error", e);
}
};

Expand Down Expand Up @@ -97,8 +93,6 @@ const syncPicturesById = async (ids: string[], token: string) => {
} catch (e) {
await set(picId, "error", getUploadStatusStore());
broadcastChannel.postMessage({ type: "status", id: picId, status: "error" });

throw e;
}
}
};
Expand Down

0 comments on commit 3499abc

Please sign in to comment.