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.
This commit is contained in:
Claude 2026-04-15 09:26:29 +00:00
parent c1c971ee47
commit e20c857e0f
No known key found for this signature in database

View file

@ -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);