⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(api): retry upload checks only on 403
Andrej8f5f73513dc5
diff --git a/apps/api/src/storage/head-uploaded-object.ts b/apps/api/src/storage/head-uploaded-object.tsindex 5d278edca..d75b7c123 100644--- a/apps/api/src/storage/head-uploaded-object.ts+++ b/apps/api/src/storage/head-uploaded-object.ts@@ -21,10 +21,6 @@ export function isMissingObjectError(error: unknown) {);}-function isNotVisibleYet(error: unknown) {- return isMissingObjectError(error) || storageStatus(error) === 403;-}-export async function headUploadedObject(client: Pick<S3Client, "send">,bucket: string,@@ -39,7 +35,7 @@ export async function headUploadedObject(try {return await head();} catch (error) {- if (!isNotVisibleYet(error) || abortSignal.aborted) throw error;+ if (storageStatus(error) !== 403 || abortSignal.aborted) throw error;}await new Promise((resolve) => setTimeout(resolve, delay));}diff --git a/tests/api/storage/head-uploaded-object.test.ts b/tests/api/storage/head-uploaded-object.test.tsindex 7145db51a..f1e48a337 100644--- a/tests/api/storage/head-uploaded-object.test.ts+++ b/tests/api/storage/head-uploaded-object.test.ts@@ -53,7 +53,7 @@ describe("headUploadedObject", () => {const send = vi.fn().mockRejectedValueOnce(storageError(403))- .mockRejectedValueOnce(storageError(404, "NotFound"))+ .mockRejectedValueOnce(storageError(403)).mockResolvedValue({ ContentLength: 12 });await expect(@@ -87,6 +87,22 @@ describe("headUploadedObject", () => {);});+ it("does not retry missing objects", async () => {+ const send = vi.fn().mockRejectedValue(storageError(404, "NotFound"));++ await expect(+ settle(+ headUploadedObject(+ { send },+ "kaneo",+ "a.png",+ new AbortController().signal,+ ),+ ),+ ).rejects.toMatchObject({ name: "NotFound" });+ expect(send).toHaveBeenCalledTimes(1);+ });+it("does not retry other storage failures", async () => {const send = vi.fn().mockRejectedValue(storageError(500));