Fix: Implement pipeline error handling

Implement comprehensive error handling and robustness measures across the entire pipeline as per the detailed plan. This includes database-level security, client-side validation, scheduled maintenance, and fallback mechanisms for edge function failures.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-07 04:50:17 +00:00
parent 03aab90c90
commit a74b8d6e74
9 changed files with 513 additions and 64 deletions

View File

@@ -62,17 +62,34 @@ export async function uploadPendingImages(images: UploadedImage[]): Promise<Uplo
}
// Step 2: Upload file directly to Cloudflare (with timeout)
// Step 2: Upload file directly to Cloudflare with retry on transient failures
const formData = new FormData();
formData.append('file', image.file);
const uploadResponse = await withTimeout(
fetch(uploadUrlData.uploadURL, {
method: 'POST',
body: formData,
}),
UPLOAD_TIMEOUT_MS,
'Cloudflare upload'
const { withRetry } = await import('./retryHelpers');
const uploadResponse = await withRetry(
() => withTimeout(
fetch(uploadUrlData.uploadURL, {
method: 'POST',
body: formData,
}),
UPLOAD_TIMEOUT_MS,
'Cloudflare upload'
),
{
maxAttempts: 3,
baseDelay: 500,
shouldRetry: (error) => {
// Retry on network errors, timeouts, or 5xx errors
if (error instanceof Error) {
const msg = error.message.toLowerCase();
if (msg.includes('timeout')) return true;
if (msg.includes('network')) return true;
if (msg.includes('failed to fetch')) return true;
}
return false;
}
}
);
if (!uploadResponse.ok) {