mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-27 20:27:04 -05:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user