fix: make screenshot retry idempotent
CI / backend-and-migrations (push) Waiting to run
CI / astro-build (push) Waiting to run
CI / dependency-audit (push) Waiting to run
CI / compose-e2e (push) Waiting to run

This commit is contained in:
ik
2026-09-22 08:17:47 +07:00
parent b1d6d8d122
commit 89dcf5f48e
3 changed files with 28 additions and 8 deletions
+4 -1
View File
@@ -12,7 +12,10 @@ export const POST: APIRoute = async ({ request, redirect, cookies }) => {
try {
const upload = new FormData(); upload.set("screenshot", screenshot);
const response = await fetch(`${base}/api/v1/catch-reports/${reportId}/screenshot`, { method: "POST", headers:{"X-Upload-Token":uploadToken}, body: upload, signal: AbortSignal.timeout(60_000) });
if (response.ok) cookies.delete(cookieName, {path:"/"});
if (response.ok) {
cookies.delete(cookieName, {path:"/"});
cookies.delete("rf4-idempotency-key", {path:"/"});
}
return redirect(response.ok ? "/report?state=screenshot_sent" : `/report?state=screenshot_error&report_id=${encodeURIComponent(reportId)}`, 303);
} catch (err) {
const isTimeout = err instanceof DOMException && err.name === "TimeoutError" ||