fix: keep screenshot recovery after timeout
This commit is contained in:
@@ -17,10 +17,9 @@ export const POST: APIRoute = async ({ request, redirect, cookies }) => {
|
||||
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" ||
|
||||
err instanceof TypeError && err.message.toLowerCase().includes("fetch") ||
|
||||
err instanceof Error && err.message.toLowerCase().includes("abort");
|
||||
return redirect(isTimeout ? `/report?state=timeout&report_id=${encodeURIComponent(reportId)}` : `/report?state=screenshot_error&report_id=${encodeURIComponent(reportId)}`, 303);
|
||||
} catch {
|
||||
// The report already exists and the upload can have reached the API before
|
||||
// the timeout. Keep the recovery form visible; the API makes a retry safe.
|
||||
return redirect(`/report?state=screenshot_error&report_id=${encodeURIComponent(reportId)}`, 303);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user