From e455840ab344cc54dabac12e392ee62d65b2bd5c Mon Sep 17 00:00:00 2001 From: glay Date: Tue, 10 Dec 2024 11:47:30 +0800 Subject: [PATCH] Update app/utils/aws.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- app/utils/aws.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/utils/aws.ts b/app/utils/aws.ts index abd98fde5f3..422c4a071bf 100644 --- a/app/utils/aws.ts +++ b/app/utils/aws.ts @@ -609,10 +609,15 @@ export function processChunks( chunks.shift(); } } catch (e) { - console.error("[Chunk Process Error]:", e); - chunks.shift(); // Remove error chunk - pendingChunk = null; // Reset pending chunk on error - } + console.warn("Failed to process chunk, attempting recovery"); + // Attempt to recover by processing the next chunk + if (chunks.length > 1) { + chunks.shift(); + pendingChunk = null; + } else { + // If this is the last chunk, throw to prevent data loss + throw new Error("Failed to process final chunk"); + } } return {