From e20c857e0f6844c8347e2bf84decbf7f991dddcc Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 09:26:29 +0000 Subject: [PATCH] fix(stream): per-envelope try/catch in replay loop A throw in a single replayed envelope used to abort the entire onResumeStreamReplay loop, skipping all subsequent envelopes in the batch. Fence still cleared via finally, so the loss was silent. Matches the per-event error handling already in clearResumeFence. --- src/lib/components/chat/Chat.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 20b70faa59..120e4e3862 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -768,7 +768,14 @@ for (const envelope of envelopes) { if (!envelope || typeof envelope !== 'object') continue; envelope._replayed = true; - await chatEventHandler(envelope); + try { + await chatEventHandler(envelope); + } catch (e) { + // Per-envelope catch so one bad frame doesn't abort + // the rest of the replay batch and silently lose the + // envelopes that come after it. + console.error('resume replay envelope error', e); + } } } finally { const current = resumeActiveRequestIdByMessageId.get(messageId);